diff --git a/src/main/java/MaximumWeightBipartiteAuctionMatching.java b/src/main/java/MaximumWeightBipartiteAuctionMatching.java index d6ed2ac..b517ee3 100644 --- a/src/main/java/MaximumWeightBipartiteAuctionMatching.java +++ b/src/main/java/MaximumWeightBipartiteAuctionMatching.java @@ -18,6 +18,7 @@ public class MaximumWeightBipartiteAuctionMatching implements MatchingAlgo private final BigDecimal delta; private final Set matching; private final BigDecimal matchingWeight; + private boolean swappedPartitions = false; public MaximumWeightBipartiteAuctionMatching(Graph graph, Set partition1, Set partition2) { this.graph = GraphTests.requireUndirected(graph); @@ -58,6 +59,7 @@ public class MaximumWeightBipartiteAuctionMatching implements MatchingAlgo else { bidders = partition2; items = partition1; + swappedPartitions = true; } /* @@ -124,12 +126,18 @@ public class MaximumWeightBipartiteAuctionMatching implements MatchingAlgo which will be the "target", so I'm using this function to make sure I get the right one. */ private V getItem(V bidder, E edge) { - if (graph.getEdgeSource(edge).equals(bidder)) { - return graph.getEdgeTarget(edge); - } - else { + if (swappedPartitions) { return graph.getEdgeSource(edge); } + else { + return graph.getEdgeTarget(edge); + } +// if (graph.getEdgeSource(edge).equals(bidder)) { +// return graph.getEdgeTarget(edge); +// } +// else { +// return graph.getEdgeSource(edge); +// } } public BigDecimal getMatchingWeight() {