use of com.graphhopper.routing.DijkstraOneToMany in project graphhopper by graphhopper.
the class NodeContractorTest method testShortestPathSkipNode2.
@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(new NodeContractor.IgnoreNodeFilter(lg, graph.getNodes() + 1).setAvoidNode(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);
}
use of com.graphhopper.routing.DijkstraOneToMany in project graphhopper by graphhopper.
the class NodeContractor method initFromGraph.
void initFromGraph() {
// todo: do we really need this method ? the problem is that ghStorage/prepareGraph can potentially be modified
// between the constructor call and contractNode,calcShortcutCount etc. ...
maxLevel = prepareGraph.getNodes() + 1;
maxEdgesCount = ghStorage.getAllEdges().getMaxId();
ignoreNodeFilter = new IgnoreNodeFilter(prepareGraph, maxLevel);
FlagEncoder prepareFlagEncoder = prepareWeighting.getFlagEncoder();
vehicleInExplorer = prepareGraph.createEdgeExplorer(new DefaultEdgeFilter(prepareFlagEncoder, true, false));
vehicleOutExplorer = prepareGraph.createEdgeExplorer(new DefaultEdgeFilter(prepareFlagEncoder, false, true));
prepareAlgo = new DijkstraOneToMany(prepareGraph, prepareWeighting, traversalMode);
}
use of com.graphhopper.routing.DijkstraOneToMany in project graphhopper by graphhopper.
the class NodeContractorTest method testShortestPathLimit.
@Test
public void testShortestPathLimit() {
createExampleGraph();
DijkstraOneToMany algo = new DijkstraOneToMany(graph, weighting, traversalMode);
setMaxLevelOnAllNodes();
algo.setEdgeFilter(new NodeContractor.IgnoreNodeFilter(lg, graph.getNodes() + 1).setAvoidNode(0));
algo.setWeightLimit(2);
int endNode = algo.findEndNode(4, 1);
// did not reach endNode
assertNotEquals(1, endNode);
}
use of com.graphhopper.routing.DijkstraOneToMany in project graphhopper by graphhopper.
the class NodeContractorTest method testShortestPathSkipNode.
@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(new NodeContractor.IgnoreNodeFilter(lg, graph.getNodes() + 1).setAvoidNode(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);
}
Aggregations