Implementation of Kruskal's algorithm for finding a minimum spanning forest of an unidirected edge-weighted graph.