Given a weighted undirected graph with V vertices, E edges, each of cost C, find which edges appear in all minimum spanning trees and which ones appear only in some minimum spanning trees. The necessary edges will be printed first, followed by the non-necassary ones. (in the same order as they appear in the input)
Input:
5 7 // 5 vertices, 7 edges
1 2 1 // First edge, from node 1 to node 2, with cost 1
2 3 1
3 4 2
4 1 2
1 5 3
4 5 3
2 5 6
Output:
// Edges that appear in all minimum spanning trees
1 2
2 3
// Edges that appear in some minimum spanning trees
3 4
4 1
1 5
4 5