We\'re given an unweighted undirected graph G = (V, E) where |V| <= 40,000 and |E| <= 106. We\'re al
This may be reduced to the shortest edge-disjoint paths problem:
Now if a = b or a' = b', you get exactly the same problem as in your previous question (which is Minimum-cost flow problem and may be solved by assigning flow capacity for each edge equal to 1, then searching for a minimum-cost flow between a and b with flow=2). If a != b, you just create a common source node and connect both a and b to it. If a' != b', do the same with a common destination node.
But if a != b and a' != b', minimum-cost flow problem is not applicable. Instead this problem may be solved as Multi-commodity flow problem.
My previous (incorrect) solution was to connect both pairs of (a, b) and (a', b') to common source/destination nodes, then to find a minimum-cost flow. Following graph is a counter-example for this approach:
How about this? Do BFS (breadth first search) traversal from a1 -> a2 and remove the path and compute BFS b1 -> b2. Now reset the graph and do same with b1->b2 first and remove path and then a1->a2. Whatever sum is minumum is the answer.