@Override public RoutingAlgorithm createAlgo(Graph g, AlgorithmOptions opts) { return new DijkstraBidirectionRef(g, opts.getWeighting(), traversalMode); } };
String algoStr = opts.getAlgorithm(); if (DIJKSTRA_BI.equalsIgnoreCase(algoStr)) { ra = new DijkstraBidirectionRef(g, opts.getWeighting(), opts.getTraversalMode()); } else if (DIJKSTRA.equalsIgnoreCase(algoStr)) { ra = new Dijkstra(g, opts.getWeighting(), opts.getTraversalMode());
@Test public void testCalcAlternatives() throws Exception { Weighting weighting = new FastestWeighting(carFE); GraphHopperStorage g = createTestGraph(true, em); AlternativeRoute altDijkstra = new AlternativeRoute(g, weighting, traversalMode); altDijkstra.setMaxShareFactor(0.5); altDijkstra.setMaxWeightFactor(2); List<AlternativeRoute.AlternativeInfo> pathInfos = altDijkstra.calcAlternatives(5, 4); checkAlternatives(pathInfos); assertEquals(2, pathInfos.size()); DijkstraBidirectionRef dijkstra = new DijkstraBidirectionRef(g, weighting, traversalMode); Path bestPath = dijkstra.calcPath(5, 4); Path bestAlt = pathInfos.get(0).getPath(); Path secondAlt = pathInfos.get(1).getPath(); assertEquals(bestPath.calcNodes(), bestAlt.calcNodes()); assertEquals(bestPath.getWeight(), bestAlt.getWeight(), 1e-3); assertEquals(IntArrayList.from(new int[]{5, 6, 3, 4}), bestAlt.calcNodes()); // Note: here plateau is longer, even longer than optimum, but path is longer // so which alternative is better? longer plateau.weight with bigger path.weight or smaller path.weight with smaller plateau.weight // assertEquals(Helper.createTList(5, 1, 9, 2, 3, 4), secondAlt.calcNodes()); assertEquals(IntArrayList.from(new int[]{5, 6, 7, 8, 4}), secondAlt.calcNodes()); assertEquals(1667.9, secondAlt.getWeight(), .1); }
String algoStr = opts.getAlgorithm(); if (DIJKSTRA_BI.equalsIgnoreCase(algoStr)) { ra = new DijkstraBidirectionRef(g, opts.getWeighting(), opts.getTraversalMode()); } else if (DIJKSTRA.equalsIgnoreCase(algoStr)) { ra = new Dijkstra(g, opts.getWeighting(), opts.getTraversalMode());
String algoStr = opts.getAlgorithm(); if (DIJKSTRA_BI.equalsIgnoreCase(algoStr)) { ra = new DijkstraBidirectionRef(g, opts.getWeighting(), opts.getTraversalMode()); } else if (DIJKSTRA.equalsIgnoreCase(algoStr)) { ra = new Dijkstra(g, opts.getWeighting(), opts.getTraversalMode());
if (DIJKSTRA_BI.equalsIgnoreCase(algoStr)) ra = new DijkstraBidirectionRef(g, opts.getFlagEncoder(), opts.getWeighting(), opts.getTraversalMode()); } else if (DIJKSTRA.equalsIgnoreCase(algoStr))