Download presentation
Presentation is loading. Please wait.
Published byΘεοδόσιος Καλάρης Modified over 5 years ago
1
Dijkstra’s Algorithm Ryan Keedy CSE 599 April 4th, 2012
2
Dijkstra’s Algorithm Description
In words: Begin with “start” node, assigning distances to the adjacent nodes Find the next (remaining) node with the shortest distance to the start, and remove it from the list If there are any remaining nodes that are closer than previously thought (via the current node), update their shortest distance Back to step 2 At any time, each node has the shortest distance for a path through the removed nodes
3
Pseudocode Set L = {1} For i = 1 to n Set D(i) = W(1,i) While V(G)\L != null set Choose k in V(G)\L with D(k) small as possible Put k in L For each j in V(G)\L If D(j) > D(k) + W(k,j) Replace D(j) by D(k) + W(k,j)
4
Modifications Made I will keep track of remaining nodes (V(G)\L), not used nodes (L) No array of costs (W) given, so we will make do without Track paths in addition to length Reduce my loops Exit outer loop when the goal node is reached Interior loop only over neighbors of the node in question (other nodes are at “infinity”)
5
Conclusions Dijkstra’s algorithm is a generalization of several others
Proved to always find the shortest path Kind of dumb, and as a result, slow
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.