Kruskal's Algorithm
A Greedy Algorithm for Minimum Spanning Tree
Steps of Kruskal's Algorithm
- Sort all edges in non-decreasing order of their weight.
- Pick the smallest edge. Check if it forms a cycle with the MST formed so far.
- If no cycle is formed, add it to the MST. Otherwise, discard it.
- Repeat until there are (V-1) edges in the MST, where V is the number of vertices.
For more details