/** * Expands the given Node in the routing algorithm; may be overridden in * sub-classes. * * @param outNode * The Node to be expanded. * @param toNode * The target Node of the route. * @param pendingNodes * The set of pending nodes so far. */ protected void relaxNode(final Node outNode, final Node toNode, final RouterPriorityQueue<Node> pendingNodes) { DijkstraNodeData outData = getData(outNode); double currTime = outData.getTime(); double currCost = outData.getCost(); if (this.pruneDeadEnds) { PreProcessDijkstra.DeadEndData ddOutData = getPreProcessData(outNode); for (Link l : outNode.getOutLinks().values()) { relaxNodeLogic(l, pendingNodes, currTime, currCost, toNode, ddOutData); } } else { // this.pruneDeadEnds == false for (Link l : outNode.getOutLinks().values()) { relaxNodeLogic(l, pendingNodes, currTime, currCost, toNode, null); } } }
/** * Logic that was previously located in the relaxNode(...) method. * By doing so, the FastDijkstra can overwrite relaxNode without copying the logic. */ /*package*/ void relaxNodeLogic(final Link l, final RouterPriorityQueue<Node> pendingNodes, final double currTime, final double currCost, final Node toNode, final PreProcessDijkstra.DeadEndData ddOutData) { if (this.pruneDeadEnds) { if (canPassLink(l)) { Node n = l.getToNode(); PreProcessDijkstra.DeadEndData ddData = getPreProcessData(n); /* IF the current node n is not in a dead end * OR it is in the same dead end as the fromNode * OR it is in the same dead end as the toNode * THEN we add the current node to the pending nodes */ if ((ddData.getDeadEndEntryNode() == null) || (ddOutData.getDeadEndEntryNode() != null) || ((this.deadEndEntryNode != null) && (this.deadEndEntryNode.getId() == ddData.getDeadEndEntryNode().getId()))) { addToPendingNodes(l, n, pendingNodes, currTime, currCost, toNode); } } } else { if (canPassLink(l)) { addToPendingNodes(l, l.getToNode(), pendingNodes, currTime, currCost, toNode); } } }
this.deadEndEntryNode = getPreProcessData(toNode).getDeadEndEntryNode();