Sunteți pe pagina 1din 4

DAA Assignment

Dijkstra's Shortest Path


Algorithm
By
B. Ravi Chandra

IPG_2014027
First Graph with Application of Dijkstras
Algorithm::
This is a directed Graph.
1
40
10 5

2 20 70
20 100
50 6
3 4
60
30
1
10 inf 20 40 inf D
1 0 1 1 0
P
1,2
10 60 20 40 inf D
1 2 1 1 0
P
1,2,4
10 50 20 40 80 D
1 4 1 4 4
P
1,2,4,5
10 50 20 40 80 D
1 4 1 4 4
P
1,2,4,5,3
10 50 20 40 80 D
1 4 1 4 4
P
1,2,4,5,3,6
10 50 20 40 80 D
1 4 1 4 4
P
P[2] P[3] P[4] P[5] P[6]
1 4 1 4 4

Vertex Distance
2 10
3 50
4 20
5 40
6 80

Second Graph with Application of Dijkstras Algorithm::


This is an undirected Graph.

4 8
8 5
4
2

4
3
3

1
4 Inf 8 inf D
1 0 1 0
P

1,2
4 7 8 18 D
1 2 1 0
P
1,2,3
4 7 8 18 D
1 2 1 0
P

1,2,3,4
4 7 8 15 D
1 2 1 0
P
1,2,3,4,5
4 7 8 15 D
1 2 1 0
P
P[2] P[3] P[4] P[5]
1 2 1 0

Vertex Distance
2 4
3 7
4 8
5 15

S-ar putea să vă placă și