The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague. Edsger Dijkstra

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.