Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Minimising Number of Bridges in a Graph

I was trying to solve a problem which basically reduces to this:
Give a set of N nodes numbered from 1 to N and M edges where N<10000 and M<100000,
Find an Edge(u,v) which when added to the graph -- Minimizes the number of bridges in the graph.
If there are many such edges - Print the one which has lowest lexicographical value.
What would be an efficient approach to this problem?

like image 919
Animesh Fatehpuria Avatar asked Feb 10 '23 11:02

Animesh Fatehpuria


1 Answers

I believe this problem is very hard. Here would be outline of the solution I can think of:

1) Find all bridges in graph.

2) Now imagine that bridges are the only edges you want in your graph. You only keep bridges and join all the nodes between bridges in big nodes.

3) You now have a tree. Edges are bridges, nodes are "big nodes" that combine nodes from previous graph.

4) Let's call this forest graph T.

5) Connecting any two nodes in graph T, creates a cycle. Any edge in the cycle is not a bridge.

6) Point 5 implies that solution is found by creating the longest cycle possible. You can do that simply by finding two nodes that have longest distance between them.

7) You can find nodes with longest distance in graph. How is discussed here: A linear-time algorithm for finding the longest distance between two nodes in a free tree?

Let me know if any point needs further explanation.

like image 147
Neithrik Avatar answered Feb 13 '23 03:02

Neithrik