protected void relaxImaginaryNode(final ImaginaryNode outNode, final RouterPriorityQueue<Node> pendingNodes, final double currTime) { double currCost = 0.0; // should be 0 for (InitialNode initialNode : outNode.initialNodes) { double travelTime = initialNode.initialTime; double travelCost = initialNode.initialCost; DijkstraNodeData data = getData(initialNode.node); Link l = null; // fromLink - use a dummy link here?? visitNode(initialNode.node, data, pendingNodes, currTime + travelTime, currCost + travelCost, l); } }
@Override protected Path constructPath(Node fromNode, Node toNode, double startTime, double arrivalTime) { ArrayList<Node> nodes = new ArrayList<Node>(); ArrayList<Link> links = new ArrayList<Link>(); nodes.add(0, toNode); Link tmpLink = getData(toNode).getPrevLink(); // Only this part has been adapted. Could probably also be changed in the super class. while (tmpLink != null) { links.add(0, tmpLink); nodes.add(0, tmpLink.getFromNode()); tmpLink = getData(tmpLink.getFromNode()).getPrevLink(); } // Ignore the initial time and cost of the start node! DijkstraNodeData startNodeData = getData(nodes.get(0)); DijkstraNodeData toNodeData = getData(toNode); Path path = new Path(nodes, links, toNodeData.getTime() - startNodeData.getTime(), toNodeData.getCost() - startNodeData.getCost()); // double travelTime = arrivalTime - startTime; // Path path = new Path(nodes, links, travelTime, toNodeData.getCost()); return path; }
/** * This method should only be called from outside after calcLeastCostPath(...) has * been executed. After that, the paths between the multiple start and/or end nodes * can be constructed using this method. * * Is there a way to check whether this method is called as intended?? * cdobler, oct'13 */ public Path constructPath(Node fromNode, Node toNode, double startTime) { if (toNode == null || fromNode == null) return null; else { DijkstraNodeData toData = getData(toNode); if (!toData.isVisited(this.getIterationId())) return null; DijkstraNodeData fromData = getData(fromNode); if (!fromData.isVisited(this.getIterationId())) return null; double arrivalTime = toData.getTime(); // now construct and return the path return constructPath(fromNode, toNode, startTime, arrivalTime); } }
stillSearching = false; } else { DijkstraNodeData data = getData(outNode); InitialNode initData = endNodes.remove(outNode.getId());