




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





Remove all loops and parallel edges from the given graph.
In case of parallel edges, keep the one which has the least cost associated and remove all others.
The next step is to create a set of edges and weight, and arrange them in an ascending order of weightage (cost). C,B omit
Now we start adding edges to the graph beginning from the one which has the least weight. Throughout, we shall keep checking that the spanning properties remain intact. In case, by adding one edge, the spanning tree property does not hold then we shall consider not to include the edge in the graph. The least cost is 2 and edges involved are B,D and D,T. We add them. Adding them does not violate spanning tree properties, so we continue to our next edge selection. Next cost is 3, and associated edges are A,C and C,D. We add them again −
By adding edge S,A we have included all the nodes of the graph and we now have minimum cost spanning tree. Below are the steps for finding MST using Kruskal’s algorithm
The algorithm is a Greedy Algorithm. The Greedy Choice is to pick the smallest weight edge that does not cause a cycle in the MST constructed so far. Let us understand it with an example: Consider the below input graph.
9 vertices the resultant of MST Kruskals alg 9-1=8 edges ADVERTISING The graph contains 9 vertices and 14 edges. So, the minimum spanning tree formed will be having (9 – 1) = 8 edges. After sorting: Weight Src Dest all 1 7 6 yes 2 8 2 yes 2 6 5 4 0 1 4 2 5 6 8 6 no 7 2 3 7 7 8 8 0 7 8 1 2 9 3 4 10 5 4 11 1 7 14 3 5
5. Pick edge 2 - 5: No cycle is formed, include it. 6. Pick edge 8 - 6: Since including this edge results in cycle, discard it. 7. Pick edge 2 - 3: No cycle is formed, include it. 8. Pick edge 7 - 8: Since including this edge results in cycle, discard it. 9. Pick edge 0 - 7: No cycle is formed, include it.
10. Pick edge 1 - 2: Since including this edge results in cycle, discard it. 11. Pick edge 3 - 4: No cycle is formed, include it. Since the number of edges included equals (V – 1), the algorithm stops here.