@Override protected Path constructPath(Node fromNode, Node toNode, double startTime, double arrivalTime) { LinkedList<Link> links = new LinkedList<>(); Link tmpLink = getData(toNode).getPrevLink(); if (tmpLink != null) { while (tmpLink.getFromNode() != fromNode) { links.add(tmpLink); tmpLink = getData(tmpLink.getFromNode()).getPrevLink(); } links.add(tmpLink); } return new Path(null, ImmutableList.copyOf(links.descendingIterator()), arrivalTime - startTime, getData(toNode).getCost()); } }
/** * 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; }
@Override public Path calcLeastCostPath(final Node fromNode, final Node toNode, final double startTime, final Person person, final Vehicle vehicle) { // yyyyyy could you please explain why this needs to be re-implemented? I would feel better if this would just use the method of // the original class. kai, jan'13 // now construct the path ArrayList<Node> nodes = new ArrayList<Node>(); ArrayList<Link> links = new ArrayList<Link>(); 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()); } // arrival time was not ok in earlier versions! DijkstraNodeData toNodeData = getData(toNode); double arrivalTime = toNodeData.getTime(); Path path = new Path(nodes, links, arrivalTime - startTime, toNodeData.getCost()); return path; }
@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; }
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();
Link tmpLink = getData(toNode).getPrevLink(); if (tmpLink != null) { links.add(0, tmpLink); nodes.add(0, tmpLink.getToNode()); tmpLink = getData(tmpLink.getToNode()).getPrevLink();
Link tmpLink = getData(toNode).getPrevLink(); if (tmpLink != null) { while (tmpLink.getFromNode() != fromNode) { links.add(((RoutingNetworkLink) tmpLink).getLink()); nodes.add(((RoutingNetworkLink) tmpLink).getLink().getToNode()); tmpLink = getData(tmpLink.getFromNode()).getPrevLink();
Link tmpLink = getData(minCostNode).getPrevLink(); while (tmpLink != null) { links.add(0, tmpLink); nodes.add(0, tmpLink.getFromNode()); tmpLink = getData(tmpLink.getFromNode()).getPrevLink();
TransitRouterNetworkLink link = (TransitRouterNetworkLink) getData(minCostNode).getPrevLink(); TransitRouterNetworkLink downstreamLink = null; Node previousFromNode = minCostNode; link = (TransitRouterNetworkLink) getData(fromNode).getPrevLink();
Link prevLink = data.getPrevLink(); if (prevLink != null && prevLink.getId().compareTo(l.getId()) > 0) { revisitNode(n, data, pendingNodes, currTime + travelTime, totalCost, l);