Shortest Path

ENGM 631
Shortest Path Solutions
Shortest Path
(10)
2
(6)
(40)
(4)
[1]
1
(2)
7
(4)
5
(Cost)
[External Flow]
(1)
(0)
(20)
(8)
3
(20)
(2)
(2)
(4)
8
(2)
(12)
(10)
(1)
4
(10)
6
(3)
(6)
9
10 [-1]
Dijkstra’s Algorithm
1. Initial : let S={s}, s=0
2. Find an arc k(i,j) that passes from an
unsolved node to a solved node such that
k (i , j )  min[ i'  ck' : k ' (i' , j' )  A, i' S , j' S ]
3. Add node j and arc k(i,j) to tree
4. Add j to solved set S. Let j=I + ck
5. Go to step 2, repeat until S = set of all nodes
Shortest Path
(10)
2
(6)
(40)
(4)
[0]
1
(8)
[8]
3
(2)
7
(4)
5
(1)
(0)
(20)
(20)
(2)
(2)
(Cost)
[s]
(4)
8
(2)
(12)
(10)
(1)
4
(10)
6
(3)
(6)
9
10
Iter
1
solved
nodes
1
closest
unsolved
3
length to
unsolved
8
node
added
3
length of
shortest path
8
Shortest Path
(10)
2
(6)
(40)
(4)
[0]
1
(8)
[8]
3
(2)
7
(4)
5
(1)
(0)
(20)
(20)
(2)
(2)
(Cost)
[s]
(4)
8
(2)
(12)
(10)
(1)
4
(10)
6
(3)
(6)
9
10
Shortest Path
(10)
2
(6)
(40)
(4)
[0]
1
(8)
[8]
3
(2)
(2)
(1)
4
[10]
(1)
(0)
[10]
(20)
(20)
(2)
(12)
(10)
7
(4)
5
(Cost)
[s]
(4)
8
(2)
(10)
6
(3)
(6)
9
10
Shortest Path
(10)
2
(6)
(40)
(4)
[0]
1
(8)
[8]
3
(2)
7
(4)
5
(1)
(0)
(20)
(20)
(2)
(2)
(Cost)
[s]
(4)
8
(2)
(12)
(10)
(1)
4
[10]
(10)
6
(3)
(6)
9
10
Iter
1
2
solved
nodes
1
1
3
closest
unsolved
3
4
6
length to
unsolved
8
10
10
node
added
3
4
length of
shortest path
8
10
Shortest Path
(10)
2
(6)
(40)
(4)
[0]
1
(8)
[8]
3
(2)
(2)
(1)
4
[10]
(1)
(0)
(20)
(20)
(2)
(12)
(10)
7
(4)
5
(Cost)
[s]
[10] (4)
8
(2)
(10)
6
(3)
(6)
9
10
Iter
1
2
3
solved
nodes
1
closest
unsolved
3
length to
unsolved
8
1
3
4
6
10
10
1
3
4
2
6
6
40
10
11
node
added
3
length of
shortest path
8
4
10
6
10
Shortest Path
[12]
(10)
2
(6)
(40)
(4)
[0]
1
(8)
[8]
3
(2)
(2)
(1)
4
[10]
(1)
(0)
(20)
(20)
(2)
(12)
(10)
7
(4)
5
(Cost)
[s]
[10] (4)
8
(2)
(10)
6
(3)
(6)
9
10
Shortest Path
[12]
(10)
2
(6)
[0]
1
(8)
7
(4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
(20)
(20)
3
(2)
[10] (4)
6
(10)
4
[10]
8
(2)
(10)
(3)
9
10
Iter
1
2
3
4
solved
nodes
1
closest
unsolved
3
length to
unsolved
8
1
3
4
6
10
10
1
3
4
2
6
6
1
3
6
2
2
9
node
added
3
length of
shortest path
8
4
10
40
10
11
6
10
40
12
13
2
12
Shortest Path
[12]
(10)
2
(6)
[0]
1
(8)
7
(4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
(20)
(20)
3
(2)
[10] (4)
6
(10)
4
[10]
8
(2)
(10)
(3)
9
10
Shortest Path
[12]
(10)
2
(6)
[0]
1
(8)
7
(4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
(20)
(20)
3
(2)
[10] (4)
6
(10)
8
(2)
(10)
(3)
4
9
[10]
[13]
10
Iter
1
2
3
4
5
solved
nodes
1
closest
unsolved
3
length to
unsolved
8
1
3
4
6
10
10
1
3
4
2
6
6
1
3
6
2
6
node
added
3
length of
shortest path
8
4
10
40
10
11
6
10
2
2
9
40
12
13
2
12
5
9
18
13
9
13
Shortest Path
[12]
(10)
2
(6)
[0]
1
(8)
7
(4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
(20)
(20)
3
(2)
[10] (4)
6
(10)
8
(2)
(10)
(3)
4
9
[10]
[13]
10
Shortest Path
[12]
(10)
2
(6)
[0]
1
(8)
7
(4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
(20)
[14] (20)
3
(2)
[10] (4)
6
(10)
8
(2)
(10)
(3)
4
9
[10]
[13]
10
Shortest Path
[12]
(10)
2
(6)
[0]
1
(8)
7
(4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
[14] (20)
3
(2)
[10] (4)
6
(10)
8
(2)
(3)
4
9
[10]
[13]
10
Iter
1
2
3
4
5
6
solved
nodes
1
closest
unsolved
3
length to
unsolved
8
1
3
4
6
10
10
1
3
4
2
6
6
1
3
6
node
added
3
length of
shortest path
8
4
10
40
10
11
6
10
2
2
9
40
12
13
2
12
2
6
5
9
18
13
9
13
2
6
9
5
8
10
18
14
15
6
14
Shortest Path
[12]
(10)
2
(6)
[0]
1
(8)
7
(4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
[14] (20)
3
(2)
[10] (4)
6
(10)
8
(2)
(3)
4
9
[10]
[13]
10
Shortest Path
[12]
(10)
2
[0]
1
(8)
7
(6) [14] (4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
[14] (20)
3
(2)
[10] (4)
6
(10)
8
(2)
(3)
4
9
[10]
[13]
10
Shortest Path
[12]
(10)
2
[0]
1
(8)
7
[14] (4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
[14]
(20)
3
(2)
[10] (4)
6
(10)
8
(2)
(3)
4
9
[10]
[13]
10
Iter
4
5
6
7
solved
nodes
closest
unsolved
length to
unsolved
1
3
6
2
2
9
40
12
13
2
6
5
9
18
13
2
6
9
5
8
10
2
8
9
7
5
10
node
added
length of
shortest path
2
12
9
13
18
14
15
6
14
22
14
15
5
14
Shortest Path
[12]
(10)
2
[0]
1
(8)
7
[14] (4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
[14]
(20)
3
(2)
[10] (4)
6
(10)
8
(2)
(3)
4
9
[10]
[13]
10
Shortest Path
[12]
(10)
2
[0]
1
(8)
7
[14] (4)
5
(4)
[8]
(Cost)
[s]
(1)
(0)
[14]
(20)
3
(2)
[10] (4)
6
(10)
8
(2)
(3)
4
9
[10]
[13]
10
[15]
Shortest Path
[12]
(10)
2
[0]
1
(8)
7
[14] (4)
5
(4)
[8]
3
(2)
(0)
[10] (4)
6
(10)
(Cost)
[s]
[14]
10
8
(2)
(3)
4
9
[10]
[13]
[15]
Iter
5
6
7
8
solved
nodes
closest
unsolved
length to
unsolved
2
6
5
9
18
13
2
6
9
5
8
10
2
8
9
2
5
8
9
node
added
length of
shortest path
9
13
18
14
15
6
14
7
5
10
22
14
15
5
14
7
7
10
10
22
18
24
15
10
15
Shortest Path
[12]
(10)
2
[14] (4)
5
(4)
[0]
1
(8)
7
[8]
3
(2)
[10] (4)
6
(10)
(0)
(Cost)
[s]
[18]
[14]
10
8
(2)
(3)
4
9
[10]
[13]
[15]
Shortest Path
[12]
2
[14] (4)
5
(4)
[0]
1
(8)
7
[8]
3
(2)
[10] (4)
6
(10)
(0)
(Cost)
[s]
[18]
[14]
10
8
(2)
(3)
4
9
[10]
[13]
[15]
Iter
5
6
7
8
9
solved
nodes
closest
unsolved
length to
unsolved
2
6
5
9
18
13
2
6
9
5
8
10
2
8
9
node
added
length of
shortest path
9
13
18
14
15
6
14
7
5
10
22
14
15
5
14
2
5
8
9
7
7
10
10
22
18
24
15
10
15
2
5
7
7
22
18
7
18