Search in sources :

Example 31 with Graph

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");
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex)

Example 32 with Graph

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);
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex)

Example 33 with Graph

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()));
    }
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) Edge(org.opentripplanner.routing.graph.Edge) HashSet(java.util.HashSet)

Example 34 with Graph

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));
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) ArrayList(java.util.ArrayList) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) Edge(org.opentripplanner.routing.graph.Edge)

Example 35 with Graph

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);
}
Also used : Vertex(org.opentripplanner.routing.graph.Vertex) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetVertex(org.opentripplanner.routing.vertextype.StreetVertex) Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge)

Aggregations

Graph (org.opentripplanner.routing.graph.Graph)105 Test (org.junit.Test)39 File (java.io.File)28 Vertex (org.opentripplanner.routing.graph.Vertex)27 RoutingRequest (org.opentripplanner.routing.core.RoutingRequest)24 StreetEdge (org.opentripplanner.routing.edgetype.StreetEdge)20 Edge (org.opentripplanner.routing.graph.Edge)19 DefaultStreetVertexIndexFactory (org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory)19 IntersectionVertex (org.opentripplanner.routing.vertextype.IntersectionVertex)19 FakeGraph (org.opentripplanner.graph_builder.module.FakeGraph)14 StreetVertex (org.opentripplanner.routing.vertextype.StreetVertex)14 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)13 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)13 GTFSPatternHopFactory (org.opentripplanner.routing.edgetype.factory.GTFSPatternHopFactory)13 GraphPath (org.opentripplanner.routing.spt.GraphPath)13 ShortestPathTree (org.opentripplanner.routing.spt.ShortestPathTree)13 TransitStop (org.opentripplanner.routing.vertextype.TransitStop)11 ArrayList (java.util.ArrayList)10 Before (org.junit.Before)10 Trip (org.onebusaway.gtfs.model.Trip)9