SPOJ Problem Set (partial)
3188. Minimum Spanning Tree
Problem code: MST

Find the minimum spanning tree of the graph.
Input
On the first line there will be two integers N  the number of nodes and M  the number of edges. (1 <= N <= 10000), (1 <= M <= 100000)
M lines follow with three integers i j k on each line representing an edge between node i and j with weight k. The IDs of the nodes are between 1 and n inclusive. The weight of each edge will be <= 1000000.
Output
Single number representing the total weight of the minimum spanning tree on this graph. There will be only one possible MST.
Example
Input:
4 5
1 2 10
2 3 15
1 3 5
4 2 2
4 3 40
Output:
17
