From b3273855a632dc07dd692958449c855b32b33704 Mon Sep 17 00:00:00 2001 From: eugenefischer <66030419+eugenefischer@users.noreply.github.com> Date: Fri, 14 Oct 2022 18:11:21 -0500 Subject: [PATCH] Test simpler source/target differentiation --- .../MaximumWeightBipartiteAuctionMatching.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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() {