Step 1 : Sort_E = Sort the set E of edges by nondecreasing order
Step 2: MST = NULL
Step 3: for each edge (u, v) in E in the nondecreasing order do
Step 4: if (MST + (u,v) does not contain cycle) then
Step 5: MST = MST + (u,v)
This algorithm can also be viewed as follows: Initially, each vertex is component. Add an edge between a pair of components to make a bigger component without any cycle. The edge chosen is a least weighted. Repeatedly add edges one after the another till we have only one component.
An implementation of the algorithm can be done using a set data structure. Each component is represented as a set. Add next least weighted edge (u,v), if u and v are in two different components or sets. That is, make a bigger component by taking the union of the sets containing u and v.
The Kurskal's algorithm using set data structure is given below.