Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shortest two disjoint paths; two sources and two destinations

We're given an unweighted undirected graph G = (V, E) where |V| <= 40,000 and |E| <= 106. We're also given four vertices a, b, a', b'. Is there a way to find two node-disjoint paths a -> a' and b -> b' such that the sum of their lengths is minimum?
My first thought was to first find the shortest path a -> a', delete it from the graph, and then find the shortest path b -> b'. I don't think this greedy approach would work.

Note: Throughout the application, a and b are fixed, while a' and b' change at each query, so a solution that uses precomputing in order to provide efficient querying would be preferable. Note also that only the minimum sum of lengths is needed, not the actual paths.

Any help, ideas, or suggestions would be extremely appreciated. Thanks a lot in advance!

like image 715
Chris Avatar asked Aug 11 '12 15:08

Chris


People also ask

Which of the algorithms will return the shortest paths between two nodes in a control flow graph?

Dijkstra's algorithm (/ˈdaɪkstrəz/ DYKE-strəz) is an algorithm for finding the shortest paths between nodes in a graph, which may represent, for example, road networks. It was conceived by computer scientist Edsger W.

Which algorithm will find the shortest path between two nodes more efficiently?

Bellman Ford's Algorithm: Bellman Ford's algorithm is used to find the shortest paths from the source vertex to all other vertices in a weighted graph.


1 Answers

This may be reduced to the shortest edge-disjoint paths problem:

  1. (Optionally) Collapse all chains in the graph into single edges. This produces a smaller weighted graph (if there are any chains in the original graph).
  2. Transform undirected graph into digraph by substituting each edge by a pair of directed edges.
  3. Split each node into the pair of nodes: one with only incoming edges of the original node, other with only its outgoing edges. Connect each pair of nodes with a single directed edge. (For example, node c in the diagram below should be split into c1 and c2; now every path containing node c in the original graph should pass through the edge c1 -> c2 in the transformed graph; here x and y represent all nodes in the graph except node c).

enter image description hereenter image description hereenter image description here

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:

enter image description here

like image 50
Evgeny Kluev Avatar answered Sep 30 '22 05:09

Evgeny Kluev