Added weighted minimum spanning tree calculation part