I have a connected undirected graph having n nodes. Given two nodes, I want to find the minimum number of edges that would have to be removed in order to ensure that there's only one cycle-free path between those two nodes.
For example, if this is the graph:
1------------2------------5
| |
| |
3-------------------------4
then given the nodes 1 and 5, the answer will be 1: just remove (for example) the edge between node 3 and node 4.
The brute-force approach is, for each subset of the set of edges, to try removing those edges and test if there's a unique cycle-free path between the two nodes of interest.
Is there a more efficient approach? (I Googled it, but did not find anything relevant.)
(Dear cryptomanic, I added these examples to help in the discussion about the exact requirements; please edit this part and indicate which of these solutions are valid. m69)
Input graph: (going from X to Y)
O---O---O---O O
/ \ / \ / \
O---O---X O Y---O---O
\ /
O---O---O---O
/ \ \
O---O O
Solution A: (no cycles inbetween X and Y)
O---O---O---O O
/ / \ / \
O---O---X O Y---O---O
/
O---O---O---O
/ \ \
O---O O
Solution B: (no side-paths inbetween X and Y)
O---O---O---O O
/ \ / \
O---O---X O Y---O---O
/
O---O---O---O
/ \ \
O---O O
Solution C: (no cycles connected to X and Y)
O---O---O---O O
/ / \ \
O---O---X O Y---O---O
/
O---O---O O
/ \ \
O---O O
Solution D: (completely isolate path from X to Y)
O---O---O---O O
/ \ / \
O---O X O Y O---O
O---O---O---O
/ \ \
O---O O
Solution E: (P can only be used once, so P-Q-R-P is not part of an alternative path)
O---O---O---O O
\ / / \
O---O---X O Y O---O
\ /
O---P---O---O
/ \ \
Q---R O
Solution F:
O---O---O---O O
\ / \ / \
O---O---X O Y---O---O
\ /
O---O---O---O
/ \ \
O---O O