6S-Shortest Path
6S-Shortest Path
2. Dijkstra Algorithm
Generate shortest paths in increasing path length order
7.6 SHORTEST PATHS
7.6.1 Find the shortest paths from a source vertex to all other vertices in G
( Single-Source Shortest-Paths Problem )
20 6
i 1 2 3 4 5 6 7 8
dist[ 5 4 ∞ 9 20 ∞ ∞
i]
4.implementation
Let a set to store the vertices of the generated shortest path
initially, there is just the source vertex v0 in U
15 1st Path : One of
2 4
5 the paths from 1 to
7
1 9 2,5,3,6
5 13
4 8
9
3 3
20 6
i 1 2 3 4 5 6 7 8
dist[ 5 4 ∞ 9 20 ∞ ∞
i]
4.implementation
Let a set to store the vertices of the generated shortest path
initially, there is just the source vertex v0 in U
15 1st Path : One of
2 4
5 the paths from 1 to
7
1 9 2,5,3,6
5 13 Add i that dist[i]is
4 8 minimum to U
9
3 i=3
3
20 6
i 1 2 3 4 5 6 7 8
dist[ 5 4 ∞ 9 20 ∞ ∞
i]
4.implementation
Let a set to store the vertices of the generated shortest path
initially, there is just the source vertex v0 in U
15 1st Path : One of
2 4
5 the paths from 1 to
7
1 9 2,5,3,6
5 13
4
Add i that dist[i]is
9 8
minimum to U i=3
3 3
7 13 After adding 3 to U,
20 6 update some dist[i]
2nd Path : One of
the paths from 1 to
i 1 2 3 4 5 6 7 8 2,5,8,6.
dist[ 5 4 ∞ 9 20 ∞ ∞
i]
4.implementation
Let a set to store the vertices of the generated shortest path
initially, there is just the source vertex v0 in U
15 1st Path : One of
2 4
5 the paths from 1 to
7
1 9 2,5,3,6
5 13
4
Add i that dist[i]is
9 8
minimum to U i=3
3 3
After adding 3 to U,
20 6 update some dist[i]
2nd Path : One of
the paths from 1 to
i 1 2 3 4 5 6 7 8 2,5,8,6.
dist[ 5 4 ∞ 9 7 ∞ 13
i]
Theorem : If the next shortest path goes to vertex x, then all
the intermediate points/vertices from the source point to x
must be in U
vo
U x
u
Theorem : If the next shortest path goes to vertex x, then all
the intermediate points/vertices from the source point to x
must be in U
vo
U x
u