KEMBAR78
Kruskal Algorithm | PPTX
Kruskal  AlgorithmKRUSKAL(V,E,W)A ← ΦFor each vertex vЄG[v]Do MAKESET[v]sort E into nondecreasing order of weight wDo if FINDSET [u]≠FINDSET[v]A ← A U {(U,V)}UNION(U,V)Return (A)
88bcd249ai14711e33105fhgGiven: G is a connected undirected weighted graph 61
First sort the edges according to nondecreasing order of their weight
88bcd249ai14711e33105fhg61        (h,g) - weight 1                    (c,f) - weight 7                             ( c,i) - weight 2                     (b,c) - weight 8         (i,h) - weight 3                     (c,d) - weight 8          ( i,g) - weight 3                     (d,e) - weight 9          (a,b) - weight 4                     (e,f) -weight 10                                 (a,h) - weight 5                     (d,f) - weight 11            (g,f) - weight 6                      (b,h)  weight 14
(h,g):Selectbcdaiefhg1
(c,i):Selectbcd2aiefhg1
Select(i,h):bcd2aie3fhg1
Reject(i,g):bcd2aie33fhg1
Select(a,b):bcd42aie3fhg1
Select(a,h):bcd24aie53fhg1
(g,f):Selectbcd42aie35fhg61
Reject(c,f):bcd24ai7e35fhg16
Select(c,d):8bcd24aie35fhg16
Reject(b,c):88bcd42aie35fhg16
Select(d,e):8bcd429aie35fhg16
Reject(e,f):8bcd429aie3510fhg16
Reject(d,f):8bcd429aie1135fhg16
Reject(b,h):8bcd429ai14e35fhg16
Minimum Spanning Tree8bcd429aie35fhg16Total weight(MST)=1+2+3+4+5+6+8+9=38

Kruskal Algorithm