Search in sources :

Example 36 with Graph

use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.

the class TestGraph method testGetStreetEdgesSeveral.

public void testGetStreetEdgesSeveral() {
    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> allStreetEdges = new HashSet<Edge>(4);
    allStreetEdges.add(edge(a, b, 1.0));
    allStreetEdges.add(edge(b, c, 1.0));
    allStreetEdges.add(edge(c, b, 1.0));
    allStreetEdges.add(edge(c, a, 1.0));
    Set<StreetEdge> edges = new HashSet<StreetEdge>(g.getStreetEdges());
    assertEquals(4, edges.size());
    assertEquals(allStreetEdges, edges);
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) IntersectionVertex(org.opentripplanner.routing.vertextype.IntersectionVertex) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) 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 37 with Graph

use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.

the class TestGraph method testGetStreetEdgesNone.

public void testGetStreetEdgesNone() {
    Graph g = new Graph();
    Vertex a = new IntersectionVertex(g, "A", 5, 5);
    Vertex b = new IntersectionVertex(g, "B", 6, 6);
    Vertex c = new IntersectionVertex(g, "C", 3, 2);
    Set<Edge> allEdges = new HashSet<Edge>(4);
    allEdges.add(new FreeEdge(a, b));
    allEdges.add(new FreeEdge(b, c));
    allEdges.add(new FreeEdge(c, b));
    allEdges.add(new FreeEdge(c, a));
    Set<StreetEdge> edges = new HashSet<StreetEdge>(g.getStreetEdges());
    assertEquals(0, edges.size());
}
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) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) StreetEdge(org.opentripplanner.routing.edgetype.StreetEdge) FreeEdge(org.opentripplanner.routing.edgetype.FreeEdge) Edge(org.opentripplanner.routing.graph.Edge) HashSet(java.util.HashSet)

Example 38 with Graph

use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.

the class TestGraph method testBasic.

public void testBasic() throws Exception {
    Graph g = new Graph();
    assertNotNull(g);
}
Also used : Graph(org.opentripplanner.routing.graph.Graph)

Example 39 with Graph

use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.

the class SimpleStreetSplitterTest method buildSpy.

@Before
public void buildSpy() {
    Graph graph = new Graph();
    SimpleStreetSplitter simpleStreetSplitter = new SimpleStreetSplitter(graph, null, null, false);
    spySimpleStreetSplitter = spy(simpleStreetSplitter);
}
Also used : Graph(org.opentripplanner.routing.graph.Graph) Before(org.junit.Before)

Example 40 with Graph

use of org.opentripplanner.routing.graph.Graph in project OpenTripPlanner by opentripplanner.

the class GtfsGraphBuilderModuleTest method testBikesByDefault.

@Test
public void testBikesByDefault() throws IOException {
    // We configure two trip: one with unknown bikes_allowed and the second with no bikes
    // allowed.
    MockGtfs gtfs = getSimpleGtfs();
    gtfs.putTrips(2, "r0", "sid0", "bikes_allowed=0,2");
    gtfs.putStopTimes("t0,t1", "s0,s1");
    List<GtfsBundle> bundleList = getGtfsAsBundleList(gtfs);
    bundleList.get(0).setDefaultBikesAllowed(true);
    _builder = new GtfsModule(bundleList);
    Graph graph = new Graph();
    _builder.buildGraph(graph, _extra);
    graph.index(new DefaultStreetVertexIndexFactory());
    // Feed id is used instead of the agency id for OBA entities.
    GtfsBundle gtfsBundle = bundleList.get(0);
    GtfsFeedId feedId = gtfsBundle.getFeedId();
    Trip trip = graph.index.tripForId.get(new AgencyAndId(feedId.getId(), "t0"));
    TripPattern pattern = graph.index.patternForTrip.get(trip);
    List<Trip> trips = pattern.getTrips();
    assertEquals(BikeAccess.ALLOWED, BikeAccess.fromTrip(withId(trips, new AgencyAndId(feedId.getId(), "t0"))));
    assertEquals(BikeAccess.NOT_ALLOWED, BikeAccess.fromTrip(withId(trips, new AgencyAndId(feedId.getId(), "t1"))));
}
Also used : Trip(org.onebusaway.gtfs.model.Trip) Graph(org.opentripplanner.routing.graph.Graph) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) GtfsBundle(org.opentripplanner.graph_builder.model.GtfsBundle) MockGtfs(org.onebusaway.gtfs.services.MockGtfs) DefaultStreetVertexIndexFactory(org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory) TripPattern(org.opentripplanner.routing.edgetype.TripPattern) Test(org.junit.Test)

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