Question:
Given a undirected graph of N nodes and M edges. You need to solve 2 problems:
- Problem 1: For each edge j (j : 1 -> M), if you delete that edge, count the number of nodes that can't reach each other (there's no path between that 2 nodes).
- Problem 2: For each node i (i : 1 -> N), if you delete that node (which also deleted all of the edges connected to it), count the number of nodes that can't reach each other.
Example:
N = 6, M = 7
1 2
2 3
3 1
3 4
4 5
5 6
6 4
(Edges are described as u - v)
Result:
- For each edge j (j : 1 -> M): 0 0 0 9 0 0 0
- For each node i (i : 1 -> N): 0 0 6 6 0 0
P/S: I have been thinking for many days but can't find a proper answer for this problem