Kruskal's partial implementation