public ShortestPathDijkstra compute(long startNode, long goalNode, Direction direction) { reset(); int node = graph.toMappedNodeId(startNode); int goal = graph.toMappedNodeId(goalNode); costs.put(node, 0.0); queue.add(node, 0.0); run(goal, direction); if (!path.containsKey(goal)) { return this; } totalCost = costs.get(goal); int last = goal; while (last != PATH_END) { finalPath.addFirst(last); finalPathCosts.addFirst(costs.get(last)); last = path.getOrDefault(last, PATH_END); } // destroy costs and path to remove the data for nodes that are not part of the graph // since clear never downsizes the buffer array costs.release(); path.release(); return this; }
public ShortestPathDijkstra compute(long startNode, long goalNode, Direction direction) { reset(); int node = graph.toMappedNodeId(startNode); int goal = graph.toMappedNodeId(goalNode); costs.put(node, 0.0); queue.add(node, 0.0); run(goal, direction); if (!path.containsKey(goal)) { return this; } totalCost = costs.get(goal); int last = goal; while (last != PATH_END) { finalPath.addFirst(last); finalPathCosts.addFirst(costs.get(last)); last = path.getOrDefault(last, PATH_END); } // destroy costs and path to remove the data for nodes that are not part of the graph // since clear never downsizes the buffer array costs.release(); path.release(); return this; }