From 51c1bc255127356b4e910ceaa5a5364534f1825a Mon Sep 17 00:00:00 2001 From: eugenefischer <66030419+eugenefischer@users.noreply.github.com> Date: Fri, 14 Oct 2022 18:09:34 -0500 Subject: [PATCH] Skip edges with zero weight --- src/main/java/MaximumWeightBipartiteAuctionMatching.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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;