ONOS-6229 KShortestPathsSearch bug fix
- KShortestPathsSearch cannot find other k-paths when the shortest path is 1 hop
Change-Id: I42d9952cc0fbc3e2fb2e3db44821a13fa0132137
diff --git a/utils/misc/src/main/java/org/onlab/graph/KShortestPathsSearch.java b/utils/misc/src/main/java/org/onlab/graph/KShortestPathsSearch.java
index 00bda43..67c9f6e 100644
--- a/utils/misc/src/main/java/org/onlab/graph/KShortestPathsSearch.java
+++ b/utils/misc/src/main/java/org/onlab/graph/KShortestPathsSearch.java
@@ -65,7 +65,7 @@
for (int k = 1; k < maxPaths; k++) {
- for (int i = 0; i < (resultPaths.get(k - 1).edges().size() - 1); i++) {
+ for (int i = 0; i < resultPaths.get(k - 1).edges().size(); i++) {
V spurNode = resultPaths.get(k - 1).edges().get(i).src();
List<E> rootPathEdgeList = resultPaths.get(k - 1).edges().subList(0, i);
@@ -88,7 +88,7 @@
spurPath.edges().forEach(totalPath::add);
//The following line must use the original weigher not the modified weigher because the modified
//weigher will count -1 values used for modifying the graph and return an inaccurate cost.
- potentialPaths.add(new DefaultPath<V, E>(totalPath,
+ potentialPaths.add(new DefaultPath<>(totalPath,
calculatePathCost(weigher, totalPath)));
}