Uses Kruskal's algorithm to find the minimal spanning tree for a graph