Shortest two disjoint paths; two sources and two destinations

前端 未结 2 1060
太阳男子
太阳男子 2021-02-04 19:50

We\'re given an unweighted undirected graph G = (V, E) where |V| <= 40,000 and |E| <= 106. We\'re al

2条回答
  •  野的像风
    2021-02-04 20:35

    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 here enter image description here enter 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

提交回复
热议问题