///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //This program is to implement Prim’s Algorithm using Greedy Method ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// import java.io.*; import java.util.*; class PRIM_MST { public int G[][],nodes,v1,v2; public PRIM_MST(int SIZE) { int i,j; G=new int[SIZE][SIZE]; for (i=0 ; ijavac PRIM_MST.java D:\DAA_MU>java PRIM_MSTDemo Prim's Algorithm Enter Number of Nodes in The Graph 7 Enter Number of Edges in The Graph 9 Enter edges and weights Enter Edge by V1 and V2 : 0 1 Enter corresponding weight :27 Enter Edge by V1 and V2 : 1 2 Enter corresponding weight :16 Enter Edge by V1 and V2 : 2 3 Enter corresponding weight :12 Enter Edge by V1 and V2 : 3 4 Enter corresponding weight :22 Enter Edge by V1 and V2 : 4 5 Enter corresponding weight :25 Enter Edge by V1 and V2 : 0 5 Enter corresponding weight :6 Enter Edge by V1 and V2 : 1 6 Enter corresponding weight :14 Enter Edge by V1 and V2 : 4 6 Enter corresponding weight :24 Enter Edge by V1 and V2 : 3 6 Enter corresponding weight :18 The adjacency matrix graph is ... 0 27 0 0 0 6 0 0 0 0 27 0 16 0 0 0 14 0 0 0 0 16 0 12 0 0 0 0 0 0 0 0 12 0 22 0 18 0 0 0 0 0 0 22 0 25 24 0 0 0 6 0 0 0 25 0 0 0 0 0 0 14 0 18 24 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 The Minimal Spanning Tree Is : Edge (0 5) and weight = 6 Edge (4 5) and weight = 25 Edge (3 4) and weight = 22 Edge (2 3) and weight = 12 Edge (1 2) and weight = 16 Edge (1 6) and weight = 14 Total Path Length Is = 95 D:\DAA_MU>