190 likes | 247 Views
Dijkstra's Shortest Path Algorithm. Find shortest path from s to t. 2. 23. 3. 9. s. 18. 14. 6. 2. 6. 4. 19. 30. 11. 5. 15. 5. 6. 16. 20. t. 7. 44. Dijkstra's Shortest Path Algorithm. S = { } PQ = ( s, 2, 3, 4, 5, 6, 7, t ). . . 2. 23. 3. 0. 9.
E N D
Dijkstra's Shortest Path Algorithm • Find shortest path from s to t. 2 23 3 9 s 18 14 6 2 6 4 19 30 11 5 15 5 6 16 20 t 7 44
Dijkstra's Shortest Path Algorithm S = { } PQ = ( s, 2, 3, 4, 5, 6, 7, t ) 2 23 3 0 9 s 18 14 6 2 6 4 19 30 11 5 15 5 6 16 20 t 7 44 distance label
Dijkstra's Shortest Path Algorithm S = { } PQ = ( s, 2, 3, 4, 5, 6, 7, t ) PQdelmin() 2 23 3 0 9 s 18 14 6 2 6 4 19 30 11 5 15 5 6 16 20 t 7 44 distance label
Dijkstra's Shortest Path Algorithm S = { s } PQ = ( 2, 6, 7, 3, 4, 5, t ) decrease key 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 4 19 30 11 5 15 5 6 16 20 t 7 44 distance label 15 X
Dijkstra's Shortest Path Algorithm S = { s } PQ = ( 2, 6, 7, 3, 4, 5, t ) PQdelmin() 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 4 19 30 11 5 15 5 6 16 20 t 7 44 distance label 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2 } PQ = ( 6, 7, 3, 4, 5, t ) 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 4 19 30 11 5 15 5 6 16 20 t 7 44 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2 } PQ = ( 6, 7, 3, 4, 5, t ) decrease key 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 4 19 30 11 5 15 5 6 16 20 t 7 44 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2 } PQ = ( 6, 7, 3, 4, 5, t ) 32 X 9 X 2 23 3 0 9 PQdelmin() s 18 14 X 14 6 2 6 4 19 30 11 5 15 5 6 16 20 t 7 44 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 6 } PQ = ( 7, 3, 5, 4, t ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 44 4 X 19 30 11 5 15 5 6 16 20 t 7 44 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 6 } PQ = ( 7, 3, 5, 4, t ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 44 4 X 19 30 11 5 15 5 6 16 20 t 7 44 15 PQdelmin() X
Dijkstra's Shortest Path Algorithm S = { s, 2, 6, 7 } PQ = ( 3, 5, t, 4 ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 35 44 X 4 X 19 30 11 5 15 5 6 16 20 t 7 44 59 X 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 6, 7 } PQ = ( 3, 5, t, 4 ) PQdelmin() 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 35 44 X 4 X 19 30 11 5 15 5 6 16 20 t 7 44 59 X 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 3, 6, 7 } PQ = ( 5, t, 4 ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 35 34 44 X X 4 X 19 30 11 5 15 5 6 16 20 t 7 44 51 59 X X 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 3, 6, 7 } PQ = ( 5, t, 4 ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 35 34 44 X X 4 X 19 30 11 5 15 5 6 16 PQdelmin() 20 t 7 44 51 59 X X 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 3, 5, 6, 7 } PQ = ( 4, t ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 45 35 34 X 44 X X 4 X 19 30 11 5 15 5 6 16 20 t 7 44 50 51 59 X X X 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 3, 5, 6, 7 } PQ = ( 4, t ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 45 35 34 X 44 X X 4 X 19 30 11 5 PQdelmin() 15 5 6 16 20 t 7 44 50 51 59 X X X 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 3, 4, 5, 6, 7 } PQ = ( t ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 45 35 34 X 44 X X 4 X 19 30 11 5 15 5 6 16 20 t 7 44 50 51 59 X X X 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 3, 4, 5, 6, 7 } PQ = ( t ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 45 35 34 X 44 X X 4 X 19 30 11 5 15 5 6 16 20 t 7 44 PQdelmin() 50 51 59 X X X 15 X
Dijkstra's Shortest Path Algorithm S = { s, 2, 3, 4, 5, 6, 7, t } PQ = ( ) 32 X 9 X 2 23 3 0 9 s 18 14 X 14 6 2 6 45 35 34 X 44 X X 4 X 19 30 11 5 15 5 6 16 20 t 7 44 PQdelmin() 50 51 59 X X X 15 X