use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TestGraph method testAddVertex.
public void testAddVertex() throws Exception {
Graph g = new Graph();
Vertex a = new IntersectionVertex(g, "A", 5, 5);
assertEquals(a.getLabel(), "A");
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TestGraph method testGetVertex.
public void testGetVertex() throws Exception {
Graph g = new Graph();
Vertex a = new IntersectionVertex(g, "A", 5, 5);
Vertex b = g.getVertex("A");
assertEquals(a, b);
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TestGraph method testGetEdgesAndVerticesById.
public void testGetEdgesAndVerticesById() {
Graph g = new Graph();
StreetVertex a = new IntersectionVertex(g, "A", 5, 5);
StreetVertex b = new IntersectionVertex(g, "B", 6, 6);
StreetVertex c = new IntersectionVertex(g, "C", 3, 2);
Set<Edge> allEdges = new HashSet<Edge>(4);
allEdges.add(edge(a, b, 1.0));
allEdges.add(edge(b, c, 1.0));
allEdges.add(edge(c, b, 1.0));
allEdges.add(edge(c, a, 1.0));
// Before rebuilding the indices, they are empty.
for (Edge e : allEdges) {
assertNull(g.getEdgeById(e.getId()));
}
for (Vertex v : g.getVertices()) {
assertNull(g.getVertexById(v.getIndex()));
}
g.rebuildVertexAndEdgeIndices();
for (Edge e : allEdges) {
assertEquals(e, g.getEdgeById(e.getId()));
}
for (Vertex v : g.getVertices()) {
assertEquals(v, g.getVertexById(v.getIndex()));
}
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TestGraph method testGetEdgesOneEdge.
public void testGetEdgesOneEdge() {
Graph g = new Graph();
Vertex a = new IntersectionVertex(g, "A", 5, 5);
Vertex b = new IntersectionVertex(g, "B", 6, 6);
FreeEdge ee = new FreeEdge(a, b);
List<Edge> edges = new ArrayList<Edge>(g.getEdges());
assertEquals(1, edges.size());
assertEquals(ee, edges.get(0));
}
use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.
the class TestGraph method testAddEdge.
public void testAddEdge() throws Exception {
Graph g = new Graph();
Vertex a = new IntersectionVertex(g, "A", 5, 5);
Vertex b = new IntersectionVertex(g, "B", 6, 6);
FreeEdge ee = new FreeEdge(a, b);
assertNotNull(ee);
}
Aggregations