Add minimum spanning tree functionality