Skip edges with zero weight

This commit is contained in:
eugenefischer
2022-10-14 18:09:34 -05:00
parent f7d522e95d
commit 51c1bc2551

View File

@@ -83,8 +83,12 @@ public class MaximumWeightBipartiteAuctionMatching<V, E> implements MatchingAlgo
BigDecimal bestValue = BigDecimal.valueOf(-1.0); BigDecimal bestValue = BigDecimal.valueOf(-1.0);
//find the item that offers the best value for this bidder //find the item that offers the best value for this bidder
for (E edge: graph.edgesOf(bidder)) { for (E edge: graph.edgesOf(bidder)) {
double weight = graph.getEdgeWeight(edge);
if(weight == 0.0) {
continue;
}
V tmp = getItem(bidder, edge); V tmp = getItem(bidder, edge);
BigDecimal value = BigDecimal.valueOf(graph.getEdgeWeight(edge)).subtract(prices.get(tmp)); BigDecimal value = BigDecimal.valueOf(weight).subtract(prices.get(tmp));
if (value.compareTo(bestValue) >= 0) { if (value.compareTo(bestValue) >= 0) {
bestValue = value; bestValue = value;
item = tmp; item = tmp;