Professional Documents
Culture Documents
Primsoutput
Primsoutput
Graph is...
0 3 11 0 0 0
3 0 5 4 2 0
11 5 0 1 0 0
0 4 1 0 10 8
0 2 0 10 0 9
0 0 0 8 9 0
No.of vertex : 6
No.of Edges : 18
After initialization....
visited [] : 0 0 0 0 0 0
d array [] : 9999 9999 9999 9999 9999 9999
p array [] : -1 -1 -1 -1 -1 -1
Edge (3,2)
Edge (3,1)
Edge (1,4)
Edge (1,0)
Edge (3,5)
Edge (1,0) : 3
Edge (3,1) : 4
Edge (3,2) : 1
Edge (1,4) : 2
Edge (3,5) : 8
Total Cost : 18
Printing Path
path from 3 to 0 is 3 --> 1 --> 0
path from 3 to 1 is 3 --> 1
path from 3 to 2 is 3 --> 2
path from 3 to 4 is 3 --> 1 --> 4
path from 3 to 5 is 3 --> 5