dijkstra s algorithm
play

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


  1. Dijkstra’s Algorithm Austin Saporito and Charlie Rizzo

  2. Test Questions 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?

  3. Austin Saporito ● I wrecked the same car twice in one month (same month I bought it) ● I’ve been slimed on Nickelodeon ● I have eaten 56 chicken nuggets in one hour ● I’ve been to Iceland ● I have an earring ● I did 2 of my own tattoos ● Wanted to be a dinosaur when I grew up ● I am doing this presentation in my underwear rn

  4. Charlie Rizzo ● Born in New Jersey ● 75% Italian + 25% Scottish ● Moved 15+ times ● I don’t like long walks on the beach ○ I burn very easily ● I wear hearing aids ● Been to Italy and Greece ○ Hiked up Mt. Olympus

  5. Charlie Rizzo ● Born in New Jersey ● 75% Italian + 25% Scottish ● Moved 15+ times ● I don’t like long walks on the beach ○ I burn very easily ● I wear hearing aids ● Been to Italy and Greece ○ Hiked up Mt. Olympus ● Been to Iceland with this cool dude →

  6. Presentation Outline 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

  7. Overview Slide ● Important Definitions ○ 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. ● Applications ○ Google maps, network routing, etc.

  8. Edsger Dijkstra ● Born on 1930 in Rotterdam, Netherlands ● Studied theoretical physics ● Held the Schlumberger Centennial Chair in Computer Sciences at The University of Texas at Austin ● He retired in 2000 ● Made a variety of algorithms ● Hates the GOTO statement ● Died in Nuenen, The Netherlands on August 6, 2002 after a long struggle with cancer

  9. Shortest Path Finding Algorithms: Beginnings ● 1950’s were when shortest path finding algorithms became the hot topic ● Shimble first proposed the idea in 1955 ● However, Bellman and Ford both get credited with the algorithm because they published it in 1958 and 1956 ○ Edward Moore also published it in 1957 ○ Sometimes you will hear it called the Bellman-Ford-Moore algorithm ● In 1959 Dijkstra published his algorithm which was essentially a rediscovery of Prim's algorithm ○ Prim's algorithm was published 2 years earlier ■ Prim’s algorithm was a rediscovery of Jarník’s algorithm

  10. Shortest Path Applications ● Popular shortest path finding application implementations: ○ 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.

  11. Real-Life Applications That Use Dijkstra’s ● Google Maps ● IP routing to find Open Shortest Path First ● The telephone network

  12. Dijkstra’s Algorithm ● Canonical shortest, weighted pathfinding algorithm ● Runtime Complexity: O (E log(V)) ● When to use? ○ One source → ALL Destinations Dijkstra's Algorithm Animated , www3.cs.stonybrook.edu/~skiena/combinatorica/animations/dijkstra.html.

  13. Algorithm - At a Glance 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

  14. Algorithm - Example Processed Not Processed 0: 0 3 1 2 1: ∞ 4 1 7 2: ∞ 9 0 5 6 3: ∞ 8 6 4: ∞ 5 3 4 5: ∞ 6: ∞

  15. Algorithm - Example Processed Not Processed 0: 0 1: ∞ 3 1 2 2: ∞ 4 1 7 3: ∞ 9 0 5 6 4: ∞ 8 6 5: ∞ 5 3 4 6: ∞

  16. Algorithm - Example Processed Not Processed 0: 0 1: 4 3 1 2 3: 8 4 1 7 2: ∞ 9 0 5 6 4: ∞ 8 6 5: ∞ 5 3 4 6: ∞

  17. Algorithm - Example Processed Not Processed 0: 0 2: 7 3 1 2 1: 4 3: 8 4 1 7 5: 11 9 0 5 6 4: ∞ 8 6 6: ∞ 5 3 4

  18. Algorithm - Example Processed Not Processed 0: 0 3: 8 3 1 2 1: 4 5: 8 4 1 7 2: 7 4: ∞ 9 0 5 6 6: ∞ 8 6 5 3 4

  19. Algorithm - Example Processed Not Processed 0: 0 5: 8 3 1 2 1: 4 4: 13 4 1 7 2: 7 6: ∞ 9 0 5 6 3: 8 8 6 5 3 4

  20. Algorithm - Example Processed Not Processed 0: 0 4: 13 3 1 2 1: 4 6: 17 4 1 7 2: 7 9 0 5 6 3: 8 8 6 5: 8 5 3 4

  21. Algorithm - Example Processed Not Processed 0: 0 6: 17 3 1 2 1: 4 4 1 7 2: 7 9 0 5 6 3: 8 8 6 5: 8 5 3 4 4: 13

  22. Algorithm - Example Processed Not Processed 0: 0 3 1 2 1: 4 4 1 7 2: 7 9 0 5 6 3: 8 8 6 5: 8 5 3 4 4: 13 6: 17

  23. Implementation of Dijkstra’s ● Implemented in C++ using multimap to hold nodes in the open/unvisited set ● 2 type of graphs generated: ○ 3 connections per node ○ 7 connections per node ● Ran on graphs with nodes ranging from 1,000 to 100,000 ○ Each run was performed 5 times and the average runtime is what’s reported ● All tests run on Macbook Pro 2.9 GHz 6-Core Intel Core i9

  24. Implementation of Dijkstra’s Nodes Closed Set Size Percentage Nodes Closed Set Size Percentage 1,000 550 55.0% 1,000 707 70.7% 10,000 7,451 74.5% 10,000 6,623 66.2% 30,000 28,074 93.6% 30,000 27,746 92.5% 50,000 22,086 44.2% 50,000 24,112 48.2% 70,000 58,499 83.6% 70,000 57,328 81.9% 90,000 90,000 57,526 63.9% 58,289 64.8%

  25. Implementation of Dijkstra’s

  26. Other Shortest Pathfinding Algorithms ● A* Algorithm ● Bellman-Ford’s Algorithm ● Floyd-Warshall’s Algorithm

  27. A-Star (A*) SPF * Algorithm ● Dijkstra’s with a heuristic ( h ) ○ h is the “estimated movement cost to move from one node to the final destination” ● Calculating h can be exact or estimated with distances ○ Manhattan, Diagonal, and Euclidean distance metrics are popular estimations for h ● Runtime Complexity: O (E) ● When to use? ○ One Source → One Destination

  28. Bellman-Ford’s SPF Algorithm ● Dijkstra’s algorithm doesn’t work for graphs with negative weight edges ○ But Bellman-Ford’s does ● For every node V, all edges are examined and an array of shortest distances to each node is built ● Runtime Complexity: O (VE) -2 ● When to use? 1 2 ○ One Source → ALL Destination Nodes 4 1 7 ■ (When graph has negative weight edges) 9 0 5 6 8 6 -1 3 4

  29. Floyd-Warshall’s SPF Algorithm ● “All Pairs Shortest Paths” ● Works on a matrix of size i * j Runtime Complexity: O (V 3 ) ● ● When to use? ○ Calculating shortest distances between EVERY pair of nodes

  30. Summary ● Dijkstra’s algorithm is very popular SPF algorithm ● Best use case is from one source to all destination nodes Runtime Algorithm Complexities O (E) A* O (E log (V)) Dijkstra’s O (VE) Bellman-Ford’s O (V 3 ) Floyd-Warshall’s

  31. Open Issues ● One of the problems with using Dijkstra’s algorithm on the Internet is that you must have a complete representation of the graph in order for the algorithm to run.

Recommend


More recommend