lec22 Graphs Shortest PAth poblem
lec22 Graphs Shortest PAth poblem
14
A path from 1 to 7.
Path length is 14.
Example
8 6
1
2 3
3 1
16
6 7 4 5 10
4
2 4 7
5 3
14
Possible algorithm:
Leave source vertex using cheapest/shortest edge.
Leave new vertex using cheapest edge subject to the
constraint that a new vertex is reached.
Continue until destination is reached.
Constructed 1 To 7 Path
8 6
1
2 3
3 1
16
6 7 4 5 10
4
2 4 7
5 3
14
1 3 6 7 11
Single Source All Destinations
1 3 5 4
Single Source All Destinations
8 6
1
2 3
3 1
16
6 7 4 5 10
4
2 4 7
5 3
14
1 3 6 [1] [2] [3] [4] [5] [6] [7]
d 0 6 2 9 5- 10 - 14
12
11
p - 1 1 5 3- - 416
3
Single Source All Destinations
Path Length
1 0
1 3 2
1 3 5 5
1 2 6
[1] [2] [3] [4] [5] [6] [7]
1 3 5 4 9
0 6 2 9 5- 10 - 14
12
11
- 1 1 5 3- 3 - 416
1 3 6 10
1 3 6 7 11
Source Single Destination