Kruskal's algorithm is a greedy algorithm. In the process, it always adds the next lowest weight edge. In order not to form a cycle, it uses find and union methods in the DisjointSet class. If two vertices of an edge don't share the same root confirmed by find method, you add this edge to MST. After adding the edge, call union method to union this two vertices so that they will not be added again.