Dijkstra’s Algorithm
Austin Saporito and Charlie Rizzo
Dijkstras Algorithm Austin Saporito and Charlie Rizzo Test - - PowerPoint PPT Presentation
Dijkstras Algorithm Austin Saporito and Charlie Rizzo Test Questions 1. What is the run time complexity of Dijkstras algorithm? 2. What case is Dijkstras algorithm best used for? 3. What was the Dijkstras algorithm a rediscovery
Austin Saporito and Charlie Rizzo
1. What is the run time complexity of Dijkstra’s algorithm? 2. What case is Dijkstra’s algorithm best used for? 3. What was the Dijkstra’s algorithm a rediscovery of?
month I bought it)
○ I burn very easily
○ Hiked up Mt. Olympus
○ I burn very easily
○ Hiked up Mt. Olympus
1. Overview 2. History 3. Applications 4. The Algorithm 5. Implementation and Results 6. Other Shortest Path Finding Algorithms 7. Open Issues 8. Summary 9. References 10. Discussion
○ Path Finding Algorithms ■ DFS, BFS, Dijkstra’s, Bellman-Ford, etc. ○ Shortest Unweighted Path Finding Algorithm ■ BFS ○ Shortest Weighted Path Finding Algorithm ■ Dijkstra’s Algorithm, Bellman-Ford, etc.
○ Google maps, network routing, etc.
at The University of Texas at Austin
struggle with cancer
and 1956 ○ Edward Moore also published it in 1957 ○ Sometimes you will hear it called the Bellman-Ford-Moore algorithm
○ Prim's algorithm was published 2 years earlier ■ Prim’s algorithm was a rediscovery of Jarník’s algorithm
○ Maps (Google, Apple, etc.) ○ Robot navigation ○ Typesetting in TeX ○ Urban traffic planning ○ Routing of telecommunications messages ○ Network routing protocols (OSPF, BGP , RIP) ○ Optimal truck routing through given traffic congestion pattern ○ Etc.
○ One source → ALL Destinations
Dijkstra's Algorithm Animated, www3.cs.stonybrook.edu/~skiena/combinatorica/animations/dijkstra.html.
1. Create two sets one that has all of the nodes we have calculated the shortest distance to from our source node (processed/closed) and a set for all other nodes (not_processed/open) 2. Initially, all nodes are in our not_processed set, and we set their distances from the source to infinity 3. While our processed set does not have all of the nodes (or the destination node).. a. Pick a node u that is not in the processed set and has the minimum distance value and include it in the processed set b. Update distance value of all adjacent vertices of u
1 2 3 4 5 6 Processed Not Processed 0: 0 1: ∞ 2: ∞ 3: ∞ 4: ∞ 5: ∞ 6: ∞ 4 8 7 5 3 1 6 9
1 2 3 4 5 6 Processed Not Processed 0: 0 1: ∞ 2: ∞ 3: ∞ 4: ∞ 5: ∞ 6: ∞ 4 8 7 5 3 1 6 9
1 2 3 4 5 6 Processed Not Processed 0: 0 1: 4 3: 8 2: ∞ 4: ∞ 5: ∞ 6: ∞ 4 8 7 5 3 1 6 9
1 2 3 4 5 6 Processed Not Processed 0: 0 2: 7 1: 4 3: 8 5: 11 4: ∞ 6: ∞ 4 8 7 5 3 1 6 9
1 2 3 4 5 6 Processed Not Processed 0: 0 3: 8 1: 4 5: 8 2: 7 4: ∞ 6: ∞ 4 8 7 5 3 1 6 9
1 2 3 4 5 6 Processed Not Processed 0: 0 5: 8 1: 4 4: 13 2: 7 6: ∞ 3: 8 4 8 7 5 3 1 6 9
1 2 3 4 5 6 Processed Not Processed 0: 0 4: 13 1: 4 6: 17 2: 7 3: 8 5: 8 4 8 7 5 3 1 6 9
1 2 3 4 5 6 Processed Not Processed 0: 0 6: 17 1: 4 2: 7 3: 8 5: 8 4: 13 4 8 7 5 3 1 6 9
1 2 3 4 5 6 Processed Not Processed 0: 0 1: 4 2: 7 3: 8 5: 8 4: 13 6: 17 4 8 7 5 3 1 6 9
○ 3 connections per node ○ 7 connections per node
○ Each run was performed 5 times and the average runtime is what’s reported
Nodes Closed Set Size Percentage 1,000 707 70.7% 10,000 6,623 66.2% 30,000 27,746 92.5% 50,000 24,112 48.2% 70,000 57,328 81.9% 90,000 58,289 64.8% Nodes Closed Set Size Percentage 1,000 550 55.0% 10,000 7,451 74.5% 30,000 28,074 93.6% 50,000 22,086 44.2% 70,000 58,499 83.6% 90,000 57,526 63.9%
○ h is the “estimated movement cost to move from one node to the final destination”
○ Manhattan, Diagonal, and Euclidean distance metrics are popular estimations for h
○ One Source → One Destination
○ But Bellman-Ford’s does
○ One Source → ALL Destination Nodes ■ (When graph has negative weight edges) 1 2 3 4 5 6 4 8 7
1 6 9
○ Calculating shortest distances between EVERY pair of nodes
Algorithm Runtime Complexities A* O(E) Dijkstra’s O(E log (V)) Bellman-Ford’s O(VE) Floyd-Warshall’s O(V3)
complete representation of the graph in order for the algorithm to run.
1. “8.20. Dijkstra's Algorithm¶.” 8.20. Dijkstra's Algorithm - Problem Solving with Algorithms and Data Structures, runestone.academy/runestone/books/published/pythonds/Graphs/DijkstrasAlgorithm.html. 2. “A* Search Algorithm.” GeeksforGeeks, 7 Sept. 2018, www.geeksforgeeks.org/a-search-algorithm/. 3. “Bellman–Ford Algorithm.” Wikipedia, Wikimedia Foundation, 10 Mar. 2020, en.wikipedia.org/wiki/Bellman–Ford_algorithm. 4. “Bellman–Ford Algorithm: DP-23.” GeeksforGeeks, 7 Aug. 2019, www.geeksforgeeks.org/bellman-ford-algorithm-dp-23/. 5. “Biography.” IEEE Computer Society Edsger Dijkstra Comments, www.computer.org/profiles/edsger-dijkstra. 6. “Dijkstra's Algorithm.” Wikipedia, Wikimedia Foundation, 14 Mar. 2020, en.wikipedia.org/wiki/Dijkstra's_algorithm. 7. Dijkstra's Algorithm Animated, www3.cs.stonybrook.edu/~skiena/combinatorica/animations/dijkstra.html. 8. “Dijsktra's Algorithm.” GeeksforGeeks, 4 Sept. 2019, www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-greedy-algo-7/. 9. “Floyd Warshall Algorithm: DP-16.” GeeksforGeeks, 18 July 2019, www.geeksforgeeks.org/floyd-warshall-algorithm-dp-16/. 10. “Overview.” Graph Theory: Networking, www.ibiblio.org/links/devmodules/graph_networking/compat/page23.html. 11. Plank, James. CS302 Lecture Notes, web.eecs.utk.edu/~jplank/plank/classes/cs302/Notes/BFS/. 12. Plank, James. CS494 Lecture Notes, web.eecs.utk.edu/~jplank/plank/classes/cs494/494/notes/A-Star/. 13. Sedgewick, Robert and Wayne, Kevin. 4.4 Shortest Paths. cs.princeton.edu/courses/archive/spr10/cos226/lectures/15-44ShortestPaths-2x2.pdf. 14. “Shortest Path Algorithms Tutorials & Notes: Algorithms.” HackerEarth, www.hackerearth.com/practice/algorithms/graphs/shortest-path-algorithms/tutorial/. 15. “The Centre for Computing History.” Centre For Computing History, www.computinghistory.org.uk/det/4179/Edsger-Dijkstra/.
earlier algorithm?
1. What is the run time complexity of Dijkstra’s algorithm? 2. What case is Dijkstra’s algorithm best used for? 3. What was the Dijkstra’s algorithm a rediscovery of?