ONOS-7490 Fixed NPE in Suurballe graph search.
Change-Id: Ib84e788988961e3802b8a09b8702df1f75380ae3
(cherry picked from commit 3702f9bdfd73a567c2bc6b417e44349318ea7f79)
diff --git a/utils/misc/src/main/java/org/onlab/graph/SuurballeGraphSearch.java b/utils/misc/src/main/java/org/onlab/graph/SuurballeGraphSearch.java
index 395a00f..ca4be92 100644
--- a/utils/misc/src/main/java/org/onlab/graph/SuurballeGraphSearch.java
+++ b/utils/misc/src/main/java/org/onlab/graph/SuurballeGraphSearch.java
@@ -69,8 +69,10 @@
public Weight weight(E edge) {
return edge instanceof ReverseEdge ?
weightf.getInitialWeight() :
- weightf.weight(edge).merge(firstDijkstra.cost(edge.src()))
- .subtract(firstDijkstra.cost(edge.dst()));
+ (weightf.weight(edge).isNegative() ?
+ new ScalarWeight(-1.0) :
+ weightf.weight(edge).merge(firstDijkstra.cost(edge.src()))
+ .subtract(firstDijkstra.cost(edge.dst())));
}
@Override