Finishing Kruskal algorithm