Minimum Spanning Tree
Hardjavapythonccppjavascript
Given a connected weighted undirected graph, find the total weight of its Minimum Spanning Tree.
Input Format
The first line contains two integers V and E. Each of the next E lines contains an undirected weighted edge u v w.
Output Format
Print the total weight of the Minimum Spanning Tree.
Example 1
Input
4 5 0 1 10 0 2 6 0 3 5 1 3 15 2 3 4
Output
19
Explanation: The MST uses edges of weight 4, 5 and 10 for a total of 19.
- 1 <= V <= 100000
- V-1 <= E <= 200000
- 0 <= w <= 1000000000
- The graph is connected.