#K5131. Graph Connectivity Under Edge Removal
Graph Connectivity Under Edge Removal
Graph Connectivity Under Edge Removal
Problem Statement:
You are given a connected undirected graph with ( n ) cities and ( m ) roads. Each road connects two distinct cities and has an associated length ( l ). Your task is to determine whether the graph remains connected after the removal of any single road. In other words, you must check if the graph is 2-edge-connected.
More formally, let the graph be ( G=(V,E) ) where ( |V|=n ) and ( |E|=m ). For every edge ( e \in E ), if the graph ( G\setminus{e} ) remains connected, then the answer is "Yes". Otherwise, the answer is "No".
Note:
- The road lengths are provided but do not affect connectivity.
- The input is given via standard input (stdin) and the output should be printed on standard output (stdout).
- It is guaranteed that the initial graph is connected.
inputFormat
The first line contains two integers ( n ) and ( m ), representing the number of cities and roads respectively.
Each of the following ( m ) lines contains three integers ( u ), ( v ), and ( l ), where ( u ) and ( v ) denote the cities connected by the road, and ( l ) is its length.
outputFormat
Output a single line containing "Yes" if the graph remains connected after removing any single road, or "No" if it does not.## sample
5 5
1 2 2
2 3 2
3 4 2
4 5 2
1 5 3
Yes
</p>