@Test public void testShortestPathLimit() { createExampleGraph(); DijkstraOneToMany algo = new DijkstraOneToMany(graph, weighting, traversalMode); setMaxLevelOnAllNodes(); algo.setEdgeFilter(createIgnoreNodeFilter(0)); algo.setWeightLimit(2); int endNode = algo.findEndNode(4, 1); // did not reach endNode assertNotEquals(1, endNode); }
prepareAlgo.setWeightLimit(existingDirectWeight); prepareAlgo.setMaxVisitedNodes(maxVisitedNodes); prepareAlgo.setEdgeFilter(ignoreNodeFilter.setAvoidNode(sch.getNode()));
@Test public void testDifferentEdgeFilter() { GraphHopperStorage g = new GraphBuilder(encodingManager).setCHGraph(new FastestWeighting(carEncoder)).create(); g.edge(4, 3, 10, true); g.edge(3, 6, 10, true); g.edge(4, 5, 10, true); g.edge(5, 6, 10, true); DijkstraOneToMany algo = (DijkstraOneToMany) createAlgo(g); algo.setEdgeFilter(new EdgeFilter() { @Override public boolean accept(EdgeIteratorState iter) { return iter.getAdjNode() != 5; } }); Path p = algo.calcPath(4, 6); assertEquals(IntArrayList.from(new int[]{4, 3, 6}), p.calcNodes()); // important call! algo.clear(); algo.setEdgeFilter(new EdgeFilter() { @Override public boolean accept(EdgeIteratorState iter) { return iter.getAdjNode() != 3; } }); p = algo.calcPath(4, 6); assertEquals(IntArrayList.from(new int[]{4, 5, 6}), p.calcNodes()); }
@Test public void testShortestPathSkipNode2() { createExampleGraph(); final double normalDist = new Dijkstra(graph, weighting, traversalMode).calcPath(4, 2).getDistance(); assertEquals(3, normalDist, 1e-5); DijkstraOneToMany algo = new DijkstraOneToMany(graph, weighting, traversalMode); setMaxLevelOnAllNodes(); algo.setEdgeFilter(createIgnoreNodeFilter(3)); algo.setWeightLimit(10); int nodeEntry = algo.findEndNode(4, 2); assertEquals(4, algo.getWeight(nodeEntry), 1e-5); nodeEntry = algo.findEndNode(4, 1); assertEquals(4, algo.getWeight(nodeEntry), 1e-5); }
@Test public void testShortestPathSkipNode() { createExampleGraph(); final double normalDist = new Dijkstra(graph, weighting, traversalMode).calcPath(4, 2).getDistance(); DijkstraOneToMany algo = new DijkstraOneToMany(graph, weighting, traversalMode); CHGraph lg = graph.getGraph(CHGraph.class); setMaxLevelOnAllNodes(); algo.setEdgeFilter(createIgnoreNodeFilter(3)); algo.setWeightLimit(100); int nodeEntry = algo.findEndNode(4, 2); assertTrue(algo.getWeight(nodeEntry) > normalDist); algo.clear(); algo.setMaxVisitedNodes(1); nodeEntry = algo.findEndNode(4, 2); assertEquals(-1, nodeEntry); }
prepareAlgo.setWeightLimit(existingDirectWeight); prepareAlgo.setMaxVisitedNodes((int) meanDegree * 100); prepareAlgo.setEdgeFilter(ignoreNodeFilter.setAvoidNode(sch.getNode()));
prepareAlgo.setWeightLimit(existingDirectWeight); prepareAlgo.setMaxVisitedNodes((int) meanDegree * 100); prepareAlgo.setEdgeFilter(ignoreNodeFilter.setAvoidNode(sch.getNode()));
prepareAlgo.setWeightLimit(existingDirectWeight); prepareAlgo.setMaxVisitedNodes(maxVisitedNodes); prepareAlgo.setEdgeFilter(ignoreNodeFilter.setAvoidNode(sch.getNode()));