Very Important Edge
InterviewTime limit3sMemory limit2048 MB
Given a weighted connected graph, find the edge whose removal gives the largest minimum spanning tree weight, and print that weight.
- Level
Medium6 of 10
- Topics
- Minimum spanning tree, Graph, Union-find
- Solved
- No attempts yet
Problem
You are given a simple connected graph where each edge has a non-negative weight. A minimum spanning tree is a connected, acyclic subset of the edges with the smallest total weight. Find the edge whose deletion maximizes the weight of the minimum spanning tree of the graph. The graph is guaranteed to stay connected after deleting any single edge.
Input
The first line contains two integers () and (), the number of vertices and the number of edges. The vertices are numbered from to . Each of the next lines contains three integers , , and (, ), describing an edge between vertices and with weight .
Output
Print a single integer, the minimum spanning tree weight of the graph after the right edge is deleted.