2

Given an undirected graph and a start and end node, I am trying to find two node-disjoint paths such that the sum of their lengths is minimized. In particular, each path must start at the start node, end at the end node, and no node (other than the start or end node) can be visited by both nodes. Is there an efficient algorithm to solve this problem?

I know that if I just need the shortest path, I can use Dijkstra's algorithm, but finding one path with Dijkstra's algorithm and then searching for another is sometimes not optimal at all, since nodes in the first path may have blocked a possible and way shorter path.

I have tried implementing the node_disjoint_path algorithm from the Python networkx package. But I must say that the result is very varying from okay to really bad. My network is not that big. "Only" 6000 nodes and 7500 edges.

D.W.
  • 167,959
  • 22
  • 232
  • 500
Denver Dang
  • 181
  • 7

1 Answers1

2

This can be solved by a small modification to Suurballe's algorithm, with $O(|E| + |V| \log |V|)$ running time. You might also be interested in Computing the k shortest edge-disjoint paths on a weighted graph.

Suurballe's algorithm works with directed graphs. You can convert an undirected graph to a directed graph by replacing each undirected edge $(u,v)$ with two directed edges $u \to v$, $v \to u$.

D.W.
  • 167,959
  • 22
  • 232
  • 500