Finished Kruskal's algorithm