Dijkstra's Algorithm Group 3 A21+A22+A23
Dijkstra's Algorithm Group 3 A21+A22+A23
Dijkstra's
ALGORITHM
By Group 3
Advantages and
disadvantages
Where,
d[u] = distance of the chosen vertex,
c(u,v) = cost from u to v,
d[v] = initial distance of v
1 2
1 6
4 5
3
3 5
Step 1
after selecting vertex 1, check for direct paths.
7
2 4
2 1
1 2
1 6
4 5
3
3 5
Step 2
Since the vertex '2' is the shortest, select it and relax other vertices.
7
∞ 7
2 4
2
1
1
4
3
4 3
Step 3
Since the vertex '3' is the shortest, select it and relax other vertices.
2 9
7
2 4
2
1
1
4
3
3 5
6
3 ∞
Step 4
now select the vertex '5' and relax other vertices.
2 9 8
7
2 4
2
1 2
∞ 11
1 6
4 5
3
3 5
3 6
Step 4
Since the vertex '4' is the shortest, select it and relax other vertices.
2 8
7
2 4
2 1
1 2
1 6 11 9
4 5
3
3 5
3 6
now all the vertices are relaxed, hence we derive the following data.
Step 2
Include the vertex in S which is nearest to K and determine shortest paths to
all vertices through this vertex and update the values. The closest vertex is c.
Step 3
continue to find shortest path vertices. now the shortest path is 'a'
Step 4
continue to find shortest path vertices. now the shortest path is 'b'
Step 5
continue to find shortest path vertices. now the shortest path is 'd'
10 5 6
A C d = 2 + 10 = 12