Microsoft interview question

Minimum spanning tree question is hard.