@Test public void testCalcDistanceDetails() { Path p = new Dijkstra(pathDetailGraph, new ShortestWeighting(encoder), TraversalMode.NODE_BASED).calcPath(1, 5); assertTrue(p.isFound()); Map<String, List<PathDetail>> details = p.calcDetails(Arrays.asList(new String[]{DISTANCE}), new PathDetailsBuilderFactory(), 0); assertTrue(details.size() == 1); List<PathDetail> distanceDetails = details.get(DISTANCE); assertEquals(5D, distanceDetails.get(0).getValue()); assertEquals(5D, distanceDetails.get(1).getValue()); assertEquals(10D, distanceDetails.get(2).getValue()); assertEquals(5D, distanceDetails.get(3).getValue()); }
@Override public Path calcPath(int from, int to) { checkAlreadyRun(); this.to = to; currEdge = new SPTEntry(from, 0); if (!traversalMode.isEdgeBased()) { fromMap.put(from, currEdge); } runAlgo(); return extractPath(); }
while (true) { visitedNodes++; if (isMaxVisitedNodesExceeded() || finished()) break; EdgeIterator iter = explorer.setBaseNode(startNode); while (iter.next()) { if (!accept(iter, currEdge.edge)) continue; continue; updateBestPath(iter, nEdge, traversalId);
@Override protected Path extractPath() { if (currEdge == null || !finished()) return createEmptyPath(); return new Path(graph, weighting). setWeight(currEdge.weight).setSPTEntry(currEdge).extract(); }
@Override public Path calcPath(int from, int to) { checkAlreadyRun(); this.to = to; currEdge = createSPTEntry(from, 0); if (!traversalMode.isEdgeBased()) { fromMap.put(from, currEdge); } runAlgo(); return extractPath(); }
@Override public RoutingAlgorithm createAlgo(Graph g, AlgorithmOptions opts) { return new Dijkstra(g, opts.getWeighting(), traversalMode); } };
public Dijkstra(Graph graph, Weighting weighting, TraversalMode tMode) { super(graph, weighting, tMode); int size = Math.min(Math.max(200, graph.getNodes() / 10), 2000); initCollections(size); }
@Override public void updateBestPath(EdgeIteratorState es, SPTEntry bestEE, int currLoc) { if (g2 != null) { mg.plotNode(g2, currLoc, Color.YELLOW); } super.updateBestPath(es, bestEE, currLoc); } }
@Override public void runAlgo() { checkAlreadyRun(); if (ignoreOneways) { outEdgeExplorer = graph.createEdgeExplorer(new DefaultEdgeFilter(encoder, true, true)); } super.runAlgo(); }
@Override public Path calcPath( int from, int to ) { checkAlreadyRun(); this.to = to; currEdge = createSPTEntry(from, 0); if (!traversalMode.isEdgeBased()) { fromMap.put(from, currEdge); } runAlgo(); return extractPath(); }
@Override protected Path extractPath() { if (currEdge == null || !finished()) return createEmptyPath(); return new Path(graph, weighting). setWeight(currEdge.weight).setSPTEntry(currEdge).extract(); }
ra = new DijkstraBidirectionRef(g, opts.getWeighting(), opts.getTraversalMode()); } else if (DIJKSTRA.equalsIgnoreCase(algoStr)) { ra = new Dijkstra(g, opts.getWeighting(), opts.getTraversalMode());
public Dijkstra(Graph graph, Weighting weighting, TraversalMode tMode) { super(graph, weighting, tMode); int size = Math.min(Math.max(200, graph.getNodes() / 10), 2000); initCollections(size); }
while (true) { visitedNodes++; if (isMaxVisitedNodesExceeded() || finished()) break; EdgeIterator iter = explorer.setBaseNode(startNode); while (iter.next()) { if (!accept(iter, currEdge.edge)) continue; continue; updateBestPath(iter, nEdge, traversalId);
@Override public Path calcPath(int from, int to) { checkAlreadyRun(); this.to = to; currEdge = new SPTEntry(from, 0); if (!traversalMode.isEdgeBased()) { fromMap.put(from, currEdge); } runAlgo(); return extractPath(); }
@Override protected Path extractPath() { if (currEdge == null || !finished()) return createEmptyPath(); return new Path(graph, flagEncoder).setWeight(currEdge.weight).setSPTEntry(currEdge).extract(); }
ra = new DijkstraBidirectionRef(g, opts.getWeighting(), opts.getTraversalMode()); } else if (DIJKSTRA.equalsIgnoreCase(algoStr)) { ra = new Dijkstra(g, opts.getWeighting(), opts.getTraversalMode());
public Dijkstra(Graph graph, Weighting weighting, TraversalMode tMode) { super(graph, weighting, tMode); int size = Math.min(Math.max(200, graph.getNodes() / 10), 2000); initCollections(size); }
@Test public void testCalcInstructionsIgnoreContinue() { // Follow a couple of straight edges, including a name change Path p = new Dijkstra(roundaboutGraph.g, new ShortestWeighting(encoder), TraversalMode.NODE_BASED) .calcPath(4, 11); assertTrue(p.isFound()); InstructionList wayList = p.calcInstructions(tr); // Contain only start and finish instruction, no CONTINUE assertEquals(2, wayList.size()); }