Skip to content

Commit d0390c2

Browse files
committed
Consider null weight to be zero instead of bailing out
1 parent a392211 commit d0390c2

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

src/MinimumSpanningTree/Kruskal.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,8 @@ public function getEdges()
4646
if ($edge instanceof EdgeDirected) {
4747
throw new UnexpectedValueException('Kruskal for directed edges not supported');
4848
}
49-
$weight = $edge->getWeight();
50-
if ($weight === NULL) {
51-
throw new UnexpectedValueException('Kruskal for edges with no weight not supported');
52-
}
5349
// Add edges with negativ Weight because of order in stl
54-
$sortedEdges->insert($edge, - $weight);
50+
$sortedEdges->insert($edge, -$edge->getWeight());
5551
}
5652
}
5753

0 commit comments

Comments
 (0)