Minimum spanning tree using Kruskal's algorithm