computes minimum spanning tree