Kruskal algorithm to calculate Minimum Spanning Tree.
GCJ 2008 Round1AA, think hard and try your best to guess the best algorithm.