Does anyone know an algorithm for the following problem:
Given a undirected connected graph find the number of ways in which 2 distinct edges can be cut such that the graph becomes disconnected.
I think a part of the problem (which i know an algorithm for) is calculating the number of ways in which 1 line can be cut so that it becomes disconnected. Then computing how these can be grouped with other lines gets the value (M-K)K + K(K-1)/2, M = no. of edges, K = no. of 1 edge cuts.
The part that i don't know how to do is finding the number of other ways to cut 2 line, for example in the graph that has only the cycle 1 - 2 - 3 - 1 any combination of the edges is a valid way of cutting lines to make the graph disconnected.
I coded the part of the program that finds all the 1 edge cuts and then I split the graph into biconnected components by removing those edges. I tried writing something for the second part, made 2 versions for that, but none of them got the right answer on every test.
The number of edges is < 100 000 , and the number of vertexes is < 2000. The program should run maximum 2 seconds on any graph with the above restrictions. Also there can be multiple edges between 2 vertexes.
I can do the first part in O(N+M). I guess the complexity for the second part should be maximum O(N*M).