tom

Fixed check-style nags.

......@@ -12,7 +12,7 @@ public class BreadthFirstSearch<V extends Vertex, E extends Edge<V>>
@Override
public Result<V, E> search(Graph<V, E> graph, V src, V dst, EdgeWeight<V, E> ew) {
checkArguments(graph, src, dst);
// Prepare the graph result.
DefaultResult result = new DefaultResult(src, dst);
......@@ -20,15 +20,16 @@ public class BreadthFirstSearch<V extends Vertex, E extends Edge<V>>
Set<V> frontier = new HashSet<>();
result.costs.put(src, 0.0);
frontier.add(src);
search: while (!frontier.isEmpty()) {
search:
while (!frontier.isEmpty()) {
// Prepare the next frontier.
Set<V> next = new HashSet<>();
// Visit all vertexes in the current frontier.
for (V vertex : frontier) {
double cost = result.cost(vertex);
// Visit all egress edges of the current frontier vertex.
for (E edge : graph.getEdgesFrom(vertex)) {
V nextVertex = edge.dst();
......@@ -38,20 +39,21 @@ public class BreadthFirstSearch<V extends Vertex, E extends Edge<V>>
cost + (ew == null ? 1.0 : ew.weight(edge)),
true);
// If we have reached our intended destination, bail.
if (nextVertex.equals(dst))
if (nextVertex.equals(dst)) {
break search;
}
next.add(nextVertex);
}
}
}
// Promote the next frontier.
frontier = next;
}
// Finally, but the paths on the search result and return.
result.buildPaths();
return result;
}
}
......
package org.onlab.graph;
import com.google.common.collect.ImmutableList;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import java.util.Iterator;
import java.util.List;
import static com.google.common.collect.ImmutableList.of;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
......
package org.onlab.graph;
import com.google.common.collect.ImmutableList;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
......@@ -8,7 +7,6 @@ import java.util.List;
import static com.google.common.collect.ImmutableList.of;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/**
* Test of the default path.
......@@ -33,8 +31,8 @@ public class DefaultPathTest extends GraphTest {
// Validates the path against expected attributes
protected void validatePath(Path<TestVertex, TestEdge> p,
TestVertex src, TestVertex dst,
int length, double cost) {
TestVertex src, TestVertex dst,
int length, double cost) {
assertEquals("incorrect path length", length, p.edges().size());
assertEquals("incorrect source", src, p.src());
assertEquals("incorrect destination", dst, p.dst());
......
package org.onlab.graph;
import com.google.common.collect.ImmutableSet;
import java.util.Set;
import static com.google.common.collect.ImmutableSet.of;
......@@ -24,11 +22,11 @@ public class GraphTest {
protected EdgeWeight<TestVertex, TestEdge> weight =
new EdgeWeight<TestVertex, TestEdge>() {
@Override
public double weight(TestEdge edge) {
return edge.weight();
}
};
@Override
public double weight(TestEdge edge) {
return edge.weight();
}
};
protected void printPaths(Set<Path<TestVertex, TestEdge>> paths) {
for (Path p : paths) {
......
package org.onlab.graph;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Ordering;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import static com.google.common.collect.ImmutableList.of;
import static org.junit.Assert.*;
......
......@@ -2,8 +2,6 @@ package org.onlab.graph;
import java.util.Objects;
import static com.google.common.base.Objects.toStringHelper;
/**
* Test vertex.
*/
......