#c22605. Minimum spanning tree for each edge
Minimum spanning tree for each edge
Minimum Spanning Tree for Each Edge
Problem Background
CF 609E
Problem Description
Given an undirected weighted simple graph with vertices and edges, with vertices numbered from to , for each edge compute the minimum total weight of a spanning tree that contains this edge.
Input Format
The first line contains two integers , the number of vertices and edges.
The next lines each contain three integers , meaning there is an edge of weight between vertex and vertex .
Output Format
Output lines in total; the -th line contains one integer, the minimum total weight of a spanning tree containing the -th edge.
Sample Input
5 7
1 2 3
1 3 1
1 4 5
2 3 2
2 5 3
3 4 2
4 5 4
Sample Output
9
8
11
8
8
8
9
Constraints
For of the data: , , , . The graph is guaranteed to be connected.