c++ program for Prim's algorithm



constructing a minimum cost spanning tree of a graph using Prim's algorithm


OUTPUT: 
  
Enter no. of vertices :8 
  
Enter no of edges :10 
  
Enter the list of edges : 
Enter an edge (u,v,wight)  :0 1 2 
  
Enter an edge (u,v,wight)  :0 2 1 
  
Enter an edge (u,v,wight)  :1 3 4 
  
Enter an edge (u,v,wight)  :1 4 2 
  
Enter an edge (u,v,wight)  :2 5 2 
  
Enter an edge (u,v,wight)  :2 6 3 
  
Enter an edge (u,v,wight)  :3 7 4 
  
Enter an edge (u,v,wight)  :4 7 3 
  
Enter an edge (u,v,wight)  :5 7 6 
  
Enter an edge (u,v,wight)  :6 7 2 
  
spanning tree matrix : 
  
List of edges in the spanning tree: 
(u,v,wight)= (0,1,2) 
(u,v,wight)= (0,2,1) 
(u,v,wight)= (1,3,4) 
(u,v,wight)= (1,4,2) 
(u,v,wight)= (2,5,2) 
(u,v,wight)= (2,6,3) 
(u,v,wight)= (6,7,2) 
Total cost of spanning tree= 16