There are two ways of constructing a software design. One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies. C.A.R. Hoare

Prime Kruskal algorithm

Language Java | Level Intermediate | Category Algorithms | August 5, 2015 7:56 am


Algorithm Problem Description

Prime Algorithm helps to find minimum-spanning-tree. Prims algorithm is useful when a graph with lots of edges. It is significantly faster in the limit when dense graph with many more edges than vertices. Kruskal performs better in sparse graphs and it uses simpler data structures.

Write program to implement prim's algorithm

Output

          	        
          	        

Minimum Spanning Tree is: 
1 -- 0
2 -- 1
3 -- 4
4 -- 5
5 -- 2
6 -- 5
7 -- 6
8 -- 2
Minimum spanning tree Cost is: 40

          	        
          	        				    


Comments



Please login to add comments.