Correctly store matching weight
This commit is contained in:
@@ -17,7 +17,7 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> implements MatchingAlgo
|
||||
private final Set<V> partition2;
|
||||
private final BigDecimal delta;
|
||||
private final Set<E> matching;
|
||||
private final BigDecimal matchingWeight;
|
||||
private BigDecimal matchingWeight;
|
||||
private boolean swappedPartitions = false;
|
||||
|
||||
public MaximumWeightBipartiteAuctionMatching(Graph<V, E> graph, Set<V> partition1, Set<V> partition2) {
|
||||
@@ -26,6 +26,7 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> implements MatchingAlgo
|
||||
this.partition2 = Objects.requireNonNull(partition2, "Partition 2 cannot be null");
|
||||
int n = Math.max(partition1.size(), partition2.size());
|
||||
this.delta = BigDecimal.valueOf(1 / ((double) n + 1));
|
||||
// this.delta = BigDecimal.valueOf(n/2);
|
||||
this.matching = new LinkedHashSet<>();
|
||||
this.matchingWeight = BigDecimal.ZERO;
|
||||
}
|
||||
@@ -35,7 +36,7 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> implements MatchingAlgo
|
||||
Method coded using MaximumWeightBipartiteMatching.class from JgraphT as a model
|
||||
*/
|
||||
@Override
|
||||
public Matching getMatching() {
|
||||
public Matching<V, E> getMatching() {
|
||||
|
||||
/*
|
||||
* Test input instance
|
||||
@@ -113,7 +114,7 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> implements MatchingAlgo
|
||||
}
|
||||
|
||||
for(E edge: matching) {
|
||||
matchingWeight.add(BigDecimal.valueOf(graph.getEdgeWeight(edge)));
|
||||
this.matchingWeight = this.matchingWeight.add(BigDecimal.valueOf(graph.getEdgeWeight(edge)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user