Simplified implementation of Kruskal's minimum spanning tree algorithm.