# Computing the k shortest edge-disjoint paths on a weighted graph

Looking for k shortest paths that do not share edges. i.e if the paths were represented as sets of edges, their intersection has to be empty.

We could use Dijkstra to find the 1st "disjoint" (edge unique) shortest path from the origin to all vertices. However, to naively find the 2nd disjoint path, one would need to create $|V|$ versions of the graph, each one with a specific set of set of edges missing, corresponding to a path that was discovered with the original Dijkstra results.

Is there a more computationally efficient method to find the $k$ shortest, edge disjoint paths? Even a heuristic would help me.

Edit:

I think this article posted by Raphael is exactly what I need to $k=2$ but I would like to support a great k if possible, up to 4. One more thing, I don't understand the following instruction:

Replace each edge of the shortest path (equivalent to two oppositely directed arcs) by a single arc directed towards the source vertex

What does "equivalent to two oppositely directed arcs" mean? What does replacing an edge with a single arc directed towards the source vertex mean?

https://en.wikipedia.org/wiki/Edge_disjoint_shortest_pair_algorithm

Wait, the problem with the above algorithm is that it doesn't lessen the complexity. It is just as efficient as running Dijkstra twice for each pair of vertices. I'm looking for a better way to get the k disjoint shortest paths between each $v_i$ and $v_j$

• Here is an article: ac.els-cdn.com/S0166218X97001212/… – wolfdawn Jun 18 '15 at 10:21
• Have you read the obvious article? Can you extend the approach to $k$? If not, where do you get stuck? – Raphael Jun 18 '15 at 15:07
• Please define what you mean by $k$ shortest paths that do not share edges. The definition is not clear to me: there are multiple possible interpretations. For instance, do you mean: go through the set of all possible paths, from shortest to longest, and take a path whenever none of its edges have been taken so far, otherwise skip it; repeat until you have $k$ paths? Or do you mean some optimization problem where we consider all possible ways of selecting $k$ edge-disjoint paths, and then minimize some objective function (e.g., the average length of those $k$ paths)? Or something else? – D.W. Jun 19 '15 at 6:01
• What do you want to tell us with this article reference? Do they define exactly the problem you want? (cf @D.W.'s comment: your statement is not clear.) Do they offer a solution? Did you not understanding something in there? – Raphael Jun 19 '15 at 12:08
• @Raphael, I read it but had trouble understanding the pseudo code. Will go over it again and ask a specific question. – wolfdawn Jun 24 '15 at 9:31

A comment by D.W. makes a lot of sense (it would do in general but it does in this specific case since there are many different variants of the same problem). Hence, in my response I just refer to a few variants of the same problem (which contain descriptions of various algorithms):

Usually, the term $k$ shortest edge-disjoint paths is plainly interpreted as follows:

Given a graph $G$ and $k$ pairs of distinct vertices $(s_i, t_i)$, $1 \leq i \leq k$, find whether there exist $k$ pairwise disjoint shortest paths $P_i$, between $s_i$ and $t_i$ for all $1 \leq i \leq k$.

And this is taken from the paper you pointed to: Tali Eilam-Tzoreff. The disjoint shortest paths problem. Discrete Applied Mathematics. Volume 85, Issue 2, pp 113--138. 1998.

This problem is known to be NP-hard for arbitrary values of $k$ but the authors actually provide a polynomial algorithm for the case of $k=2$ with positive edge-costs.

In this variant, there is no interest in minimizing any particular metric. The best result, to the best of my knowledge, refers to Directed Acyclic Graphs (DAGs) and $k=2$:

Torsten Tholey. Linear time algorithms for two disjoint paths problems on directed acyclic graphs. Theoretical Computer Science, 465:35–48, 2012

However, the oldest formulation I know of this problem actually considers the minimization of a specific metric:

Given a directed graph G containing $n$ vertices, one of which is a distinguished source $s$, and $m$ edges, each with a non-negative cost, find a pair of edge-disjoint paths from $s$ to $v$ of minimum total cost.

This problem is known to be a special case of minimum-cost network flow, and there is a brilliant, splendid, beautiful and amazing algorithm for solving it with $k=2$: Suurballe's algorithm.

Another variant that has received some attention imposes a limit on the number of edges (and these are known as Length Constraints):

Given a graph $G$ compute a pair of disjoint paths between nodes $s$ and $t$ of an undirected graph, each having at most $K$ edges.

Approximation algorithms have been developed also for this particular variant. See: Longkun Guo. Frontiers in Algorithmics, volume 8497 of Lecture Notes in Computer Science, chapter Improved LP-rounding Ap- proximations for the k-Disjoint Restricted Shortest Paths Problem, pages 94–104. Springer International Publishing, 2014.

In all these works (but the first two ones), the authors refer to shortest paths but watch out what D.W. is asking in his comment: this is not to find the minimum number $m$ of shortest paths from which a set of $k$ shortest paths could be extracted such that they do not share any edge. In general, the computation of these $k$ shortest paths refer to an additional metric. For example, Tragoudas and Varol consider the minimization of the maximum length and Guo introduces the minimization of an additional parameter, $delay$.

Summarizing, there are many variants of the same problem, Suurballe's minimizes the sum of the cost of the pair of paths, others consider the minimization of the longest path (Tragoudas and Varol), and this is known as a min-max version but also max-min versions exist and this is just in case a metric is used. If not, it depends whether you impose limits or not on the length of the paths and other cases. All of them, however, are known to be exponentially hard.

I would like to end just by pointing out that I am not aware of any generalization of A$^*$-like search algorithms that deal with this problem. I think that can be definitely an interesting line of research.

Hope this helps,

• Thanks! What I'm attempting to do is find the k shortest disjoint paths between a specific vertex and all other vertices. i.e if Dijkstra gives the shortest path between u and every vi in G then I need k such iterations where each iterations avoids edges of paths in the previous iterations for each vi... meaning edges from a previous path to v2 could be used in a path to v9 but not in an additional path to v2 and vice versa. – wolfdawn Jun 24 '15 at 10:49
• @zehelvion: Not really sure I see your point. First, Dijkstra does not compute the shortest path between the source vertex and all other vertices. It just computes the shortest path between two vertices (and, from here, also the shortest path to all paths in closed, but this is just a side product). If my understanding is correct, the only variation of your case with regard to other problems is that you want $k$ different edge-disjoint shortest paths, each one wrt to a different goal state. This should amount to apply an algorithm $k$ times, isn't it? – Carlos Linares López Jun 24 '15 at 14:11
• Running Disjkstra once, does construct a tree of shortest paths, to all vertices from a specific origin. Meaning, this can be done without affecting complexity. However, computing k shortest paths, requires that we remove a specific path to a specific destination and run disjkstra again. This means that going for k paths would require running it $k * |V|$ times which is time consuming (each time eliminating the union of a specific set of paths). – wolfdawn Jun 24 '15 at 16:42
• Oh, I see your point now. Usually, by "running Dijkstra" I understand let the algorithm run until the goal state is about to be expanded. Of course, you can let it run until the queue is exhausted without affecting complexity. Now, most (if not all) of the algorithms described in the papers I cited reduce the overall complexity you mention. – Carlos Linares López Jun 25 '15 at 8:09
• But I think they don't find $k$ disjoint paths from the origin to $v_i$ for each $i$? – wolfdawn Jun 25 '15 at 11:57