Using Kruskal's and Union-Find algorithms to find the minimum spanning tree of a graph