Test simpler source/target differentiation
This commit is contained in:
@@ -18,6 +18,7 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> implements MatchingAlgo
|
|||||||
private final BigDecimal delta;
|
private final BigDecimal delta;
|
||||||
private final Set<E> matching;
|
private final Set<E> matching;
|
||||||
private final BigDecimal matchingWeight;
|
private final BigDecimal matchingWeight;
|
||||||
|
private boolean swappedPartitions = false;
|
||||||
|
|
||||||
public MaximumWeightBipartiteAuctionMatching(Graph<V, E> graph, Set<V> partition1, Set<V> partition2) {
|
public MaximumWeightBipartiteAuctionMatching(Graph<V, E> graph, Set<V> partition1, Set<V> partition2) {
|
||||||
this.graph = GraphTests.requireUndirected(graph);
|
this.graph = GraphTests.requireUndirected(graph);
|
||||||
@@ -58,6 +59,7 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> implements MatchingAlgo
|
|||||||
else {
|
else {
|
||||||
bidders = partition2;
|
bidders = partition2;
|
||||||
items = partition1;
|
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.
|
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) {
|
private V getItem(V bidder, E edge) {
|
||||||
if (graph.getEdgeSource(edge).equals(bidder)) {
|
if (swappedPartitions) {
|
||||||
return graph.getEdgeTarget(edge);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return graph.getEdgeSource(edge);
|
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() {
|
public BigDecimal getMatchingWeight() {
|
||||||
|
|||||||
Reference in New Issue
Block a user