Showing
6 changed files
with
4 additions
and
14 deletions
... | @@ -21,7 +21,8 @@ public class BreadthFirstSearch<V extends Vertex, E extends Edge<V>> | ... | @@ -21,7 +21,8 @@ public class BreadthFirstSearch<V extends Vertex, E extends Edge<V>> |
21 | result.costs.put(src, 0.0); | 21 | result.costs.put(src, 0.0); |
22 | frontier.add(src); | 22 | frontier.add(src); |
23 | 23 | ||
24 | - search: while (!frontier.isEmpty()) { | 24 | + search: |
25 | + while (!frontier.isEmpty()) { | ||
25 | // Prepare the next frontier. | 26 | // Prepare the next frontier. |
26 | Set<V> next = new HashSet<>(); | 27 | Set<V> next = new HashSet<>(); |
27 | 28 | ||
... | @@ -38,8 +39,9 @@ public class BreadthFirstSearch<V extends Vertex, E extends Edge<V>> | ... | @@ -38,8 +39,9 @@ public class BreadthFirstSearch<V extends Vertex, E extends Edge<V>> |
38 | cost + (ew == null ? 1.0 : ew.weight(edge)), | 39 | cost + (ew == null ? 1.0 : ew.weight(edge)), |
39 | true); | 40 | true); |
40 | // If we have reached our intended destination, bail. | 41 | // If we have reached our intended destination, bail. |
41 | - if (nextVertex.equals(dst)) | 42 | + if (nextVertex.equals(dst)) { |
42 | break search; | 43 | break search; |
44 | + } | ||
43 | next.add(nextVertex); | 45 | next.add(nextVertex); |
44 | } | 46 | } |
45 | } | 47 | } | ... | ... |
1 | package org.onlab.graph; | 1 | package org.onlab.graph; |
2 | 2 | ||
3 | -import com.google.common.collect.ImmutableList; | ||
4 | import com.google.common.testing.EqualsTester; | 3 | import com.google.common.testing.EqualsTester; |
5 | import org.junit.Test; | 4 | import org.junit.Test; |
6 | 5 | ||
7 | -import java.util.Iterator; | ||
8 | -import java.util.List; | ||
9 | - | ||
10 | import static com.google.common.collect.ImmutableList.of; | 6 | import static com.google.common.collect.ImmutableList.of; |
11 | import static org.junit.Assert.assertEquals; | 7 | import static org.junit.Assert.assertEquals; |
12 | import static org.junit.Assert.assertNull; | 8 | import static org.junit.Assert.assertNull; | ... | ... |
1 | package org.onlab.graph; | 1 | package org.onlab.graph; |
2 | 2 | ||
3 | -import com.google.common.collect.ImmutableList; | ||
4 | import com.google.common.testing.EqualsTester; | 3 | import com.google.common.testing.EqualsTester; |
5 | import org.junit.Test; | 4 | import org.junit.Test; |
6 | 5 | ||
... | @@ -8,7 +7,6 @@ import java.util.List; | ... | @@ -8,7 +7,6 @@ import java.util.List; |
8 | 7 | ||
9 | import static com.google.common.collect.ImmutableList.of; | 8 | import static com.google.common.collect.ImmutableList.of; |
10 | import static org.junit.Assert.assertEquals; | 9 | import static org.junit.Assert.assertEquals; |
11 | -import static org.junit.Assert.assertNull; | ||
12 | 10 | ||
13 | /** | 11 | /** |
14 | * Test of the default path. | 12 | * Test of the default path. | ... | ... |
1 | package org.onlab.graph; | 1 | package org.onlab.graph; |
2 | 2 | ||
3 | -import com.google.common.collect.ImmutableList; | ||
4 | import com.google.common.collect.Ordering; | 3 | import com.google.common.collect.Ordering; |
5 | import com.google.common.testing.EqualsTester; | 4 | import com.google.common.testing.EqualsTester; |
6 | import org.junit.Test; | 5 | import org.junit.Test; |
7 | 6 | ||
8 | import java.util.ArrayList; | 7 | import java.util.ArrayList; |
9 | import java.util.Comparator; | 8 | import java.util.Comparator; |
10 | -import java.util.Iterator; | ||
11 | 9 | ||
12 | import static com.google.common.collect.ImmutableList.of; | 10 | import static com.google.common.collect.ImmutableList.of; |
13 | import static org.junit.Assert.*; | 11 | import static org.junit.Assert.*; | ... | ... |
-
Please register or login to post a comment