use of com.graphhopper.util.EdgeExplorer in project graphhopper by graphhopper.
the class Dijkstra method runAlgo.
protected void runAlgo() {
EdgeExplorer explorer = outEdgeExplorer;
while (true) {
visitedNodes++;
if (isMaxVisitedNodesExceeded() || finished())
break;
int startNode = currEdge.adjNode;
EdgeIterator iter = explorer.setBaseNode(startNode);
while (iter.next()) {
if (!accept(iter, currEdge.edge))
continue;
int traversalId = traversalMode.createTraversalId(iter, false);
double tmpWeight = weighting.calcWeight(iter, false, currEdge.edge) + currEdge.weight;
if (Double.isInfinite(tmpWeight))
continue;
SPTEntry nEdge = fromMap.get(traversalId);
if (nEdge == null) {
nEdge = new SPTEntry(iter.getEdge(), iter.getAdjNode(), tmpWeight);
nEdge.parent = currEdge;
fromMap.put(traversalId, nEdge);
fromHeap.add(nEdge);
} else if (nEdge.weight > tmpWeight) {
fromHeap.remove(nEdge);
nEdge.edge = iter.getEdge();
nEdge.weight = tmpWeight;
nEdge.parent = currEdge;
fromHeap.add(nEdge);
} else
continue;
updateBestPath(iter, nEdge, traversalId);
}
if (fromHeap.isEmpty())
break;
currEdge = fromHeap.poll();
if (currEdge == null)
throw new AssertionError("Empty edge cannot happen");
}
}
Aggregations