#P4628. Instability Degree of a Local Area Network
Instability Degree of a Local Area Network
Instability Degree of a Local Area Network
In a local area computer network, there are (n) computers and (m) cables. Each cable connects two computers and allows bidirectional communication. The network is guaranteed to be connected, meaning any two computers can (directly or indirectly) communicate.
During the preparation period, the team leader wishes to assess the network’s robustness. Consider the following failure scenario: a computer (A) suddenly fails (is removed) and, at the same time, a cable (L) (which is not incident to (A)) is cut off. After these removals, only the remaining (n-1) computers are considered. If not every pair of these computers can communicate (i.e. the graph becomes disconnected), then the pair ((A, L)) is considered unstable.
The instability degree of the network is defined as the total number of different choices of a computer (A) and a cable (L) (with (L) not incident to (A)) such that after removing (A) and cable (L) from the network, the remaining computers are not fully connected.
More formally, for each computer (A), let (G_A) be the graph obtained by removing (A) and all cables incident with (A) from the original graph. Then, for each cable (L) in the original graph that does not connect to (A), if removing (L) from (G_A) results in a disconnected graph (or if (G_A) is already disconnected), the pair ((A,L)) is counted. Your task is to compute the instability degree of the network.
Note: All formulas are given in (\LaTeX) format.
inputFormat
The first line contains two integers (n) and (m) ( (1 \leq n, m \leq 10^5)), representing the number of computers and cables, respectively. Each of the next (m) lines contains two integers (u) and (v) ((1 \le u, v \le n, u \neq v)) indicating that there is a cable connecting computer (u) and computer (v). It is guaranteed that the network is connected.
outputFormat
Output a single integer: the instability degree of the network -- the total number of ways to choose a computer (A) and a cable (L) (with (L) not incident to (A)) such that after removing (A) and (L), the remaining network is disconnected.
sample
4 4
1 2
2 3
3 4
4 1
8