Search in sources :

Example 1 with StopGraphComparator

use of org.onebusaway.transit_data_federation.impl.StopGraphComparator in project onebusaway-application-modules by camsys.

the class RouteBeanServiceImpl method getStopsInOrder.

private List<StopEntry> getStopsInOrder(StopSequenceCollection block) {
    DirectedGraph<StopEntry> graph = new DirectedGraph<StopEntry>();
    for (StopSequence sequence : block.getStopSequences()) {
        StopEntry prev = null;
        for (StopEntry stop : sequence.getStops()) {
            if (prev != null) {
                // We do this to avoid cycles
                if (!graph.isConnected(stop, prev))
                    graph.addEdge(prev, stop);
            }
            prev = stop;
        }
    }
    StopGraphComparator c = new StopGraphComparator(graph);
    return graph.getTopologicalSort(c);
}
Also used : DirectedGraph(org.onebusaway.transit_data_federation.impl.DirectedGraph) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) StopGraphComparator(org.onebusaway.transit_data_federation.impl.StopGraphComparator) StopSequence(org.onebusaway.transit_data_federation.model.StopSequence)

Aggregations

DirectedGraph (org.onebusaway.transit_data_federation.impl.DirectedGraph)1 StopGraphComparator (org.onebusaway.transit_data_federation.impl.StopGraphComparator)1 StopSequence (org.onebusaway.transit_data_federation.model.StopSequence)1 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)1