Test simpler source/target differentiation

This commit is contained in:
eugenefischer
2022-10-14 18:11:21 -05:00
parent 51c1bc2551
commit b3273855a6

View File

@@ -18,6 +18,7 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> implements MatchingAlgo
private final BigDecimal delta;
private final Set<E> matching;
private final BigDecimal matchingWeight;
private boolean swappedPartitions = false;
public MaximumWeightBipartiteAuctionMatching(Graph<V, E> graph, Set<V> partition1, Set<V> partition2) {
this.graph = GraphTests.requireUndirected(graph);
@@ -58,6 +59,7 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> implements MatchingAlgo
else {
bidders = partition2;
items = partition1;
swappedPartitions = true;
}
/*
@@ -124,12 +126,18 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> 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() {