Skip to content
Snippets Groups Projects
Commit bca22cc6 authored by Pedro Pablo Cardona Arroyave's avatar Pedro Pablo Cardona Arroyave
Browse files

Some changes

parent 4b4192dd
Branches
No related tags found
No related merge requests found
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -147,6 +147,8 @@ class Graph{
adjacencyList.get(start).add(new Edge(start,destination, drivingTime));
}
//TODO: ADD GOBALITY TO Dijkstra
public List<Edge> getShortestPath(int startNumber, int destinationNumber){
PriorityQueue<Edge> priorityQueue = new PriorityQueue<>();
int nodeSize = adjacencyList.size();
......@@ -165,12 +167,14 @@ class Graph{
int start = nextEdge.start();
int currentSum = pathWeight[start] + nextEdge.drivingTime();
if(currentSum<pathWeight[nextNode]) {
pathWeight[nextNode] = currentSum;
pathToNodes[nextNode] = new ArrayList<>(pathToNodes[start]);
pathToNodes[nextNode].add(nextEdge);
priorityQueue.addAll(adjacencyList.get(nextNode));
}
}
if(visited[destinationNumber]) return pathToNodes[destinationNumber];
}
return pathToNodes[destinationNumber];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment