Kruskal’s algorithm for finding the Minimum Spanning Tree(MST), which finds an edge of the least possible weight that connects any two trees in the forest

It is a greedy algorithm.

It finds a subset of the edges that forms a tree that includes every vertex, where the total weight of all the edges in the tree is minimized.

If the graph is not connected, then it finds a minimum spanning forest (a minimum spanning tree for each connected component).

Number of edges in MST: V-1 (V – no of vertices in Graph).

Pick the edge with the least weight. Check if including this edge in spanning tree will form a cycle is Yes then ignore it if No then add it to spanning tree.

Repeat the step 2 till spanning tree has V-1 (V – no of vertices in Graph).

Spanning tree with least weight will be formed, called Minimum Spanning Tree

Pseudo Code:

KRUSKAL(G):
A = ∅
foreach v ∈ G.V:
MAKE-SET(v)
foreach (u, v) in G.E ordered by weight(u, v), increasing:
if FIND-SET(u) ≠ FIND-SET(v):
A = A ∪ {(u, v)}
UNION(u, v)
return A

If you find anything incorrect or you feel that there is any better approach to solve the above problem, please write comment.
__________________________________________________