/** * Returns the data for the given Node. Creates a new AStarNodeData if none exists yet. * * @param n The node for which to return the data for.. * @return The data to the given Node */ @Override protected AStarNodeData getData(final Node n) { return (AStarNodeData) super.getData(n); }
/** * Initializes the first node of a route. * * @param fromNode * The Node to be initialized. * @param toNode * The Node at which the route should end. * @param startTime * The time we start routing. * @param pendingNodes * The pending nodes so far. */ /*package*/ void initFromNode(final Node fromNode, final Node toNode, final double startTime, final RouterPriorityQueue<Node> pendingNodes) { DijkstraNodeData data = getData(fromNode); visitNode(fromNode, data, pendingNodes, startTime, 0, null); }
/** * Resets all nodes in the network as if they have not been visited yet. */ private void resetNetworkVisited() { for (Node node : this.network.getNodes().values()) { DijkstraNodeData data = getData(node); data.resetVisited(); } }
/** * Constructs the path after the algorithm has been run. * * @param fromNode * The node where the path starts. * @param toNode * The node where the path ends. * @param startTime * The time when the trip starts. */ protected Path constructPath(Node fromNode, Node toNode, double startTime, double arrivalTime) { List<Node> nodes = new ArrayList<>(); List<Link> links = new ArrayList<>(); nodes.add(0, toNode); Link tmpLink = getData(toNode).getPrevLink(); if (tmpLink != null) { while (tmpLink.getFromNode() != fromNode) { links.add(0, tmpLink); nodes.add(0, tmpLink.getFromNode()); tmpLink = getData(tmpLink.getFromNode()).getPrevLink(); } links.add(0, tmpLink); nodes.add(0, tmpLink.getFromNode()); } DijkstraNodeData toNodeData = getData(toNode); Path path = new Path(nodes, links, arrivalTime - startTime, toNodeData.getCost()); return path; }
/** * 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); } } }
DijkstraNodeData outData = getData(foundToNode); double arrivalTime = outData.getTime();
final DijkstraNodeData data = getData(n); if (!data.isVisited(getIterationId())) { visitNode(n, data, pendingNodes, currTime + travelTime, currCost + travelCost, l);