Solution for Minimum spanning tree