diff --git a/src/main/java/MaximumWeightBipartiteAuctionMatching.java b/src/main/java/MaximumWeightBipartiteAuctionMatching.java index 988b917..d6ed2ac 100644 --- a/src/main/java/MaximumWeightBipartiteAuctionMatching.java +++ b/src/main/java/MaximumWeightBipartiteAuctionMatching.java @@ -83,8 +83,12 @@ public class MaximumWeightBipartiteAuctionMatching implements MatchingAlgo BigDecimal bestValue = BigDecimal.valueOf(-1.0); //find the item that offers the best value for this bidder for (E edge: graph.edgesOf(bidder)) { + double weight = graph.getEdgeWeight(edge); + if(weight == 0.0) { + continue; + } 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) { bestValue = value; item = tmp;