commit | 26df2f2dd5f3f8a3252a98a8f4c5e3aa892f1b73 | [log] [tgz] |
---|---|---|
author | Thomas Vachuska <tom@onlab.us> | Wed Nov 26 13:25:22 2014 -0800 |
committer | Gerrit Code Review <gerrit@onlab.us> | Thu Nov 27 00:39:26 2014 +0000 |
tree | 3117fd55a2e00f64af9970eb3cf6f8ca8d08209c | |
parent | deb8a1098d9d5439acc2f8460a7e3b6d688fc583 [diff] |
Added short-circuit to Dijkstra when there are no edges. Change-Id: I7e647ffceeae9de1736c5f36159c33d882bdb9f2
diff --git a/utils/misc/src/main/java/org/onlab/graph/DijkstraGraphSearch.java b/utils/misc/src/main/java/org/onlab/graph/DijkstraGraphSearch.java index e0628c1..eada84c 100644 --- a/utils/misc/src/main/java/org/onlab/graph/DijkstraGraphSearch.java +++ b/utils/misc/src/main/java/org/onlab/graph/DijkstraGraphSearch.java
@@ -38,6 +38,11 @@ // Cost to reach the source vertex is 0 of course. result.updateVertex(src, null, 0.0, false); + if (graph.getEdges().isEmpty()) { + result.buildPaths(); + return result; + } + // Use the min priority queue to progressively find each nearest // vertex until we reach the desired destination, if one was given, // or until we reach all possible destinations.