Efficient Algorithms for the Disjoint Shortest Paths Problem and Its Extensions
Abstract
We study the 2-Disjoint Shortest Paths (2-DSP) problem: given a directed weighted graph and two terminal pairs and , decide whether there exist vertex-disjoint shortest paths between each pair.
Building on recent advances in disjoint shortest paths for DAGs and undirected graphs (Akmal et al. 2024), we present an -time algorithm for this problem in weighted directed graphs that do not contain negative or zero weight cycles. This algorithm presents a significant improvement over the previously known -time bound (Berczi et al. 2017). Our approach exploits the algebraic structure of polynomials that enumerate shortest paths between terminal pairs. A key insight is that these polynomials admit a recursive decomposition, enabling efficient evaluation via dynamic programming over fields of characteristic two. Furthermore, we demonstrate how to report the corresponding paths in -time.
In addition, we extend our techniques to a more general setting: given two terminal pairs and in a directed graph, find the minimum possible number of vertex intersections between any shortest path from to and to . We call this the Minimum 2-Disjoint Shortest Paths (Min-2-DSP) problem. We provide in this paper the first efficient algorithm for this problem, including an -time algorithm for directed graphs with positive edge weights, and an -time algorithm for DAGs and undirected graphs. Moreover, if the number of intersecting vertices is at least one, we show that it is possible to report the paths in the same -time. This is somewhat surprising, as there is no known time algorithm for explicitly reporting the paths if they are vertex-disjoint, and is left as an open problem in (Akmal et al. 2024).
Keywords and phrases:
Disjoint paths, Disjoint shortest paths, Algebraic graph algorithmsFunding:
Lakshay Saggi: Supported by Prime Minister’s Research Fellowship (PMRF).Copyright and License:
2012 ACM Subject Classification:
Mathematics of computing Graph algorithmsAcknowledgements:
The authors are thankful to Shyan Akmal for his detailed and valuable feedback.Editor:
Shubhangi SarafSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
The 2-Disjoint Shortest Paths (2-DSP) problem seeks to determine whether a graph contains two vertex-disjoint paths such that each path is a shortest path between its designated source and target vertices. More formally, given a weighted graph with edge weights and two source-target pairs and , the goal is to determine whether there exist vertex-disjoint paths and , where is a shortest -path and is a shortest -path.
The 2-DSP problem is a fundamental problem in combinatorial optimization with applications in network flows, routing, and circuit design [20, 22, 23]. Beyond its practical relevance, the problem has attracted significant attention because its complexity varies across graph classes, giving rise to a rich algorithmic landscape.
The 2-DSP problem has a rich history of algorithmic results. Eilam-Tzoreff [12] gave the first polynomial-time algorithm for 2-DSP in undirected graphs with running time . This was improved by Akhmedov [1] to for the weighted case and for the unweighted case. Bentert et al. [6] obtained an algorithm for unweighted undirected graphs. More recently, Akmal, Vassilevska Williams, and Wein [4] achieved an optimal algorithm for weighted undirected graphs, and extended their techniques to obtain the same bound for weighted DAGs. Their algorithm employs an algebraic framework based on path-enumerating polynomials, where cancellations over a field of characteristic two are used to detect disjoint shortest paths.
The situation is markedly different for general directed graphs. Here, the first polynomial-time algorithm was given only recently by Bérczi and Kobayashi [7], whose method requires strictly positive edge weights and runs in time.111This running time is obtained by reducing to the edge disjoint version of the 2-DSP problem. However, we feel that a direct implementation of their approach to vertex-disjoint setting would also require cycling over subsets of size four from the set of vertices, and hence, would incur time. Thus, despite decades of progress in the undirected setting, the directed case has remained far less understood, with a substantial gap between known upper bounds and what might be achievable.
Our work addresses the central question: Can 2-DSP be solved efficiently in general directed weighted graphs? We give an affirmative answer that significantly improves the running time of 2-DSP problem. Our work builds on the framework of [4] by employing algebraic techniques for suitable enumerating polynomials. However, the complexity of path intersections in general directed graphs poses new challenges and we require significantly new ideas to obtain a recursive decomposition of these polynomials.
We also introduce and study a natural relaxation of 2-DSP. When no pair of vertex-disjoint shortest paths exists, one may instead ask for two shortest paths whose overlap is as small as possible. This motivates the Minimum 2-Disjoint Shortest Paths (Min-2-DSP) problem: given two source–target pairs and , find shortest paths and minimizing , where denotes the vertex set of path . Our techniques extend naturally to this more general problem, yielding the first polynomial-time algorithms for Min-2-DSP across several graph classes. The problem is inherently more intricate than 2-DSP, since it requires reasoning not only about the existence of disjoint paths but also about quantifying and optimizing the extent of their intersections.
1.1 Our Contributions
Our first result presents a polynomial-time algorithm for 2-DSP in directed weighted graphs without negative or zero-weight cycles, providing the first efficient algorithm in this general setting. Further, it significantly improves the previously best-known -time bound even for the special case of directed graphs with strictly positive edge weights.
Theorem 1.1.
The 2-DSP problem in directed weighted graphs having no cycles of negative or zero weight is solvable in time. Moreover, we can report the explicit paths, if they exist, in time.
It is crucial to note that the graph considered in the theorem above must not contain zero-weight cycles. This is because if zero weight cycles are allowed, then the 2-Disjoint Paths (2-DP) problem which is NP-hard in directed graphs [13] becomes a special case of the 2-DSP problem.
We next consider the Min-2-DSP problem in directed graphs with positive edge weights. This result provides the first algorithmic framework for minimizing path intersections in the directed setting, showing that even this more general objective remains polynomial-time solvable.
Theorem 1.2.
The Min-2-DSP problem in directed graphs with positive edge weights is solvable in time. Moreover, we can report the explicit paths in time bound.
For structured graph classes, we obtain significantly faster algorithms. In particular, for DAGs we achieve an optimal linear-time bound.
Theorem 1.3.
The Min-2-DSP problem in weighted DAGs is solvable in time. Moreover, if we are guaranteed that no disjoint paths exist, then there exists an algorithm which also reports the explicit paths in the same time.
Finally, we extend these results to undirected graphs with positive edge weights, again achieving optimal complexity.
Theorem 1.4.
The Min-2-DSP problem in undirected graphs with positive edge weights is solvable in time. Moreover, if we are guaranteed that no disjoint paths exist, then there exists an algorithm which also reports the explicit paths in the same time.
1.2 Related Work
For , the -DSP problem complexity landscape becomes dramatically more challenging, and the complexity landscape diverges sharply between undirected and directed graphs. In undirected graphs, Lochet [18] provided the first polynomial-time algorithm for -DSP (for constant ), though with a running time of , which was later improved to by Bentert et al. [6]. It is worth noting that is the best we can hope for in undirected graphs, due to -Hardness and fine-grained lower bounds established in [6, 18, 4]. Hence, reducing the exponent from to remains an important open problem for -DSP in undirected graphs. In an interesting breakthrough, Pilipczuk, Stamoulis and Wlodarczyk [21] recently claimed an FPT algorithm for -DSP in undirected planar graphs, providing the first non-trivial graph class to admit such an algorithm.
In contrast, the situation is far less understood for directed graphs with : no polynomial-time algorithms are known, and no hardness results have been established either. The complexity of -DSP in directed graphs therefore remains wide open. Nevertheless, -time algorithms are known for certain restricted classes, including DAGs [4, 7, 13] and planar digraphs [7].
A different line of work considers the objective of finding vertex-disjoint paths that minimize the total length of the paths. For undirected graphs, Björklund and Husfeldt [8] developed an algebraic algorithm for the case of two paths with running time . This running time was subsequently improved to by Björklund, Husfeldt, and Kaski [9]. For , the problem remains open even in undirected graphs, and since this objective generalizes -DSP, it inherits all of its hardness barriers [6, 18]. More recently, Mari et al. [19] obtained an FPT algorithm for rectangular grid graphs for this objective.
Another natural objective extending the -DSP problem is to maximize the number of source–target pairs that can be connected by vertex-disjoint shortest paths. Clearly this problem inherits the lower-bound barriers of -DSP, making it natural to ask whether efficient approximation algorithms are possible. However, recent hardness results by Chitnis et al. [10] and Bentert et al. [5] rule out even such approximation approaches, underscoring the inherent difficulty of the problem.
To the best of our knowledge, the Min-2-DSP objective has not been studied previously. A related direction appears in the work of Funayama et al. [14], who consider the problem of finding shortest – paths that minimize the total number of pairwise vertex intersections among them. We leave the Min--DSP as an open problem, for , for undirected as well as directed graphs.
1.3 Organization of the Paper
We introduce the necessary notations, definitions, and algebraic tools in Section 2. An overview of our techniques is provided in Section 3. Our -time algorithm for the 2-DSP problem in general directed graphs is presented in Section 4. The results on the Min-2-DSP problem for directed graphs are discussed in Section 5, while Min-2-DSP results for DAGs and undirected graphs are deferred to the full version [11]. Proofs and technical details omitted from the main exposition are also included in the full version [11].
2 Preliminaries
Let be a directed or undirected graph. For any vertex , let and denote the set of in-neighbors and in-edges of , respectively, and let denote the size of these sets. Define , , and analogously. For any two vertices , let denote the length of the shortest path from to in , and let denote the set of all shortest paths from to . We say that a vertex is a ‘distance-critical vertex’ for the pair if its removal increases the distance from to , i.e., . Let denote the set of all distance-critical vertices for pair , including the endpoints and ; and define . Observe that .
Given a path , we denote by and the sets of vertices and edges that appear on respectively. Given any two vertices , we say precedes on , denoted by , if either or appears before on . For vertices and a path where precedes on , let denote the sub-path of from to . Similarly, for a vertex , an edge , and path where precedes , let denote the subpath . Define for a suitable , and analogously. Given two paths and , their concatenation is denoted by , provided that the last vertex of coincides with the first vertex of . Given vertices and , let and denote the sets of all vertices and edges that lie on at least one shortest path between and in respectively. Formally,
Definition 2.1 (Internally vertex-disjoint paths).
Let and be two pairs of vertices. A pair of distinct paths, one from to and the other from to , are said to be internally vertex-disjoint if they do not share any vertices except those in the set .
In general, when two directed paths intersect at several vertices, the order in which these vertices appear in the two paths respectively could be different. The following lemma shows that there is more structure when these are shortest paths with a common destination.
Lemma 2.2.
Let be vertices and and . Suppose and intersect internally and let be the set of vertices in . Then the relative order of the vertices in is the same in both and .
Proof.
Suppose for the sake of contradiction that there are vertices such that appears before in , but after in . Since each sub-path of is also a shortest path, we see that , but the reverse inequality is implied by the position of and in . This leads to a contradiction.
Definition 2.3 (Twin-crossing paths).
Two paths and are said to be twin-crossing if there exist distinct vertices such that precedes in both paths, and the sub-paths and are not identical to each other. Here, is referred to as twin-crossing pair for paths and .
Lemma 2.4 (Schwartz-Zippel lemma).
Let be a non-zero polynomial of degree over a finite field . If a point is selected uniformly at random from , then the probability that evaluates to a non-zero value is at least .
In this paper, we will work with fields of characteristic two. Thus will be , for some integer . We will be working with which is . This would support addition and multiplication over in constant time in the Word-RAM model.
Enumerating Polynomials
For each edge , we introduce an indeterminate (also denoted by ). For any simple path consisting of edges , we associate with it a monomial
If is an empty-path (that is, has zero edges), then is defined to be . Note that the monomials corresponding to any two distinct simple paths are distinct. We now proceed to define the concept of enumerating polynomials.
Definition 2.5 (Enumerating polynomial).
Given a collection of paths, the enumerating polynomial for is defined as Similarly, for a collection of pairs of paths, the enumerating polynomial for the collection is defined as
For any , we use to denote the enumerating polynomial , where , i.e., the set of all shortest paths from to in . That is,
[4] showed that can be evaluated efficiently, we give a proof below for the sake of completeness.
Lemma 2.6.
Let be a directed weighted graph with no negative weight cycles. For any assignment , the polynomial , for all , can be evaluated in time.
Proof.
We first compute the all-pairs distance matrix using Johnson’s algorithm [16] in time. Using this matrix, we evaluate for all as follows:
| (1) |
where the membership can be verified in constant time using the distance matrix (recall that is the set of edges that appear on a shortest path from to ). To compute efficiently for all vertex pairs, we fix a source vertex and construct the DAG . We then process the vertices of in topological order, ensuring that for each vertex , all required values in Eq. 1 have already been computed prior to evaluating . Since each edge in is processed once per source , the computation of values for all pairs can be performed in time, given the distance matrix of . Therefore, the overall computation takes time.
Definition 2.7 (Swap operation).
For any pair of paths and any such that precedes in both the paths, we define to be the pair of paths obtained by swapping segments between and in . That is, if has endpoints , then , for . We refer to as a swap operation at .
The following claim proves that the swap operation is an involution.
Claim 2.8.
Let be a pair of paths in with as a twin-crossing pair, and let Then the pair also has as twin-crossing. Further, and the pair is distinct from .
Proof.
Let and be shortest paths between pairs and with as a twin-crossing pair, i.e., . Define . Since both and are shortest paths, exchanging and between them yields and that are also shortest paths from to and to , respectively.
Moreover, applying again to restores the original pair , since the swapped segments are simply exchanged back. As , is distinct from , and both share as a twin-crossing pair because . Thus, the claim holds.
3 Technical Overview
In this section, we outline the technical novelties of our contribution.
3.1 2-DSP: From DAGs to Directed Graphs
[4] studied the -DSP problem for DAGs and undirected graphs, achieving optimal linear-time algorithms. The main idea behind their approach was to compute enumerating polynomials whose monomials are products of edge variables for each choice of vertex-disjoint and shortest paths. The polynomial enumerates all shortest path pairs with no disjointness constraints.
For solving -DSP, they showed that it suffices to cancel the effect of intersecting paths from this total enumeration. Their key insight was that twin-crossing paths contribute zero in a field of characteristic : if are twin-crossing at vertices , then swapping the segments between and results in paths with the same monomial contribution as , and these contributions cancel each other in a characteristic field. For the remaining case, namely, the scenario where non-twin crossing paths intersect for the first time at some vertex , they gave techniques that, after precomputing all relevant values, require only time per vertex . Summing over all vertices resulted in the time algorithm.
Challenge in Directed graphs.
In directed graphs, the main challenge is that paths may intersect in more complicated ways, and there is no universally consistent “first common intersection” between and due to the absence of a global topological ordering. See Figure 1. Unlike DAGs where intersection patterns follow predictable structures, directed shortest paths can intersect and separate multiple times in a complex manner.
Our Approach.
To tackle this complexity, we solve the -DSP problem by studying intersection patterns with respect to the first intersection point on a reference path . Observe that in DAGs, a vertex is the unique first intersection point for and if and only if prefixes of and up to are internally vertex-disjoint. In comparison, in general directed graph, a vertex is the first vertex on that is common between and if and only if the prefixes of and up to , and the suffix of from to , all these three segments, are internally vertex-disjoint. See Figure 1.
We define to be the enumerating polynomial of pairs such that
| (2) |
are internally vertex-disjoint, or equivalently, is the first vertex on that is common between . Thus, if denotes the enumerating polynomial of all disjoint pairs of paths , then
Indeed, the second term in the right-hand side captures all intersecting pairs by cycling over all choices of the first vertex on where this intersection occurs. Thus, it suffices to check if the above polynomial is non-zero. Now, the disjointness conditions in (2) can be relaxed as follows: instead of requiring that and are disjoint, we just require that the incoming edges of in these two paths respectively are distinct. Indeed, if and intersect while the incoming edges of are distinct in these two prefixes, then there exist a common vertex such that forms a twin crossing pair for . But again, a standard swapping argument shows the contribution of such pairs in the sum gets canceled in a field of characteristic .
In order to exploit the above observation, we define two additional polynomials. For any , define to be the enumerating polynomial of pairs containing that satisfy
are internally vertex-disjoint. Further, for any in-edge of , define analogously with an additional requirement that the paths must contain the edge . The discussion above shows that , for any , is given by (see Section 4 for a more formal proof):
The definition of shows that it can be expressed in terms of , and similarly for (see Lemma 4.1 and 4.2). Thus, we are able to recursively express in terms of polynomials over a different set of quadruples. Finally, we show that overall only quadruples are encountered in such manner, and their computation (i.e., evaluation over randomly chosen values) can be done efficiently using dynamic programming.
3.2 Solving Min-2-DSP in general directed graphs
The Minimum-2-Disjoint Shortest Paths (Min-2-DSP) problem is significantly more challenging than the standard 2-DSP problem. Let and be the input source-destination pairs, and let denote the minimum possible overlap between any pair (we call such a pair an optimal pair).
One could define a suitable enumerating polynomial of all such optimal pairs. The first challenge in computing arises when every optimal pair is twin-crossing. Indeed, the standard swap operation would result in another optimal pair such that the contributions of and would cancel out in the enumerating polynomial. While this cancellation property was crucial in our algorithm for the standard 2-DSP problem, it inadvertently causes the cancellation of contributions from optimal solutions in the Min-2-DSP setting. To overcome this limitation, we introduce the notion of a concordant pair.
Definition 3.1 (Concordant pair).
Let and be two paths with endpoints and , respectively. A pair of vertices , not contained in the set , is said to be a concordant pair for and if either , or appears before on and ; and the subpaths are internally vertex-disjoint, and likewise are internally vertex-disjoint.
Note that for general directed graphs, there can be multiple concordant pairs with respect to any pair of intersecting paths (see Figure 2). We denote by the set of all concordant pairs with respect to paths .
Lemma 3.2.
Let be a pair of paths, and be the concordant pairs with respect to . Then, the following holds.
-
1.
Vertex-disjointness For , and are empty sets; that is, the subpaths corresponding to concordant pairs on (resp. ) are vertex-disjoint.
-
2.
Order Reversal If the concordant pairs are ordered along as , then on this ordering is exactly reversed.
Intuitively, the concordant pairs capture the structural overlap for any pair of paths having minimum overlap. In order to explain this we present the following observation.
Observation 3.3.
For any , there exist two shortest paths from to in (possibly identical) that intersect only at -distance critical vertices.
Proof.
Define a subgraph of by including only those edges that satisfy
That is, contains exactly those edges that participate in some shortest path from to , for . It follows that is acyclic, and for any , there is a bijection between -shortest-paths in and -paths in . This implies that the cut vertices for pair in correspond exactly to the -distance critical vertices in . By applying the Menger’s theorem to , we obtain two paths from to in , intersecting at only -cut vertices. These paths correspond to two -shortest paths in that intersect only at -distance critical vertices.
As a corollary we get the following.
Lemma 3.4.
For any and shortest paths intersecting at exactly internal vertices and any , the subpaths of from to have vertices in common. Furthermore, these common vertices are precisely the -distance-critical vertices.
This suggests a shift in strategy: rather than directly searching for an optimal path pair, we can search for a pair of paths such that the total count of distance-critical vertices across all concordant pairs is minimized. This leads us to the following definition.
Definition 3.5.
The interaction complexity of two paths and is defined as
Note that if is an optimal solution to Min-2-DSP then . We define as the enumerating polynomial of all pair of paths in that have at most interaction complexity. Our goal is to return the smallest for which is non-zero.
In order to compute , we introduce several helper polynomials and present relations between them. These are more complicated in nature, so we defer the discussion to Section 5.
3.3 Solving Min-2-DSP in DAGs and Undirected graphs
For DAGs and undirected graphs, the Min-2-DSP problem admits a simpler and more efficient time algorithm. First assume that given pairs and , the desired minimum number of intersections between any pair of paths is strictly positive (otherwise, we can employ the results in [4]). For a vertex , let denote the minimum number of intersections of any pair of paths such that lies on both of these paths. Since the optimal pair of paths must intersect at some vertex, it is not hard to show that is equal to (if does not lie on any pair of paths in , we can assume to be infinity).
A naive method for calculating would be following: (i) find the shortest paths with minimum number of intersections (call this number ) and (ii) find the shortest paths with minimum number of intersections (call this number ). If is DAG, or if is undirected and , then it can be seen that . For each vertex , and can be computed in time by building dominator trees [17, 15] in appropriate subgraphs of . This results in overall running time of .
While it may seem that computing for any fixed takes time, our main insight is that this computation can be done more efficiently, such that computing over all takes total time. For doing so, we take inspiration from the notion of bicoloured components defined by Lochet [18] and partitioning the vertex set into smaller components where Min-2-DSP reduces to Min-2-DP.
4 2-DSP in Directed graphs
For any vertex pairs and , let be the enumerating polynomial of the collection of all pairs such that and are internally vertex-disjoint.
Observe that the polynomial is non-zero (in a field of characteristic 2) if and only if there exist two shortest paths, one from to and the other from to , that are internally vertex-disjoint. This follows from the fact that each such pair contributes a distinct monomial to , determined by the set of edges used along both paths. Indeed, if is a pair of internally vertex-disjoint shortest paths for and , then for each , the path from to remains unique in the subgraph , unless the two vertex pairs coincide.
4.1 Helper polynomials
In this subsection, we will provide construction of various helper polynomials that will be crucial in solving 2-DSP in directed graphs. The helper polynomials introduced in this section will be helpful in providing a recursive formulation for the polynomial .
I. Disjoint Prefix-Suffix linkages up to a Shared Vertex/Edge
For any , let be the enumerating polynomial of all pairs such that
-
1.
, and
-
2.
Prefix and suffix are internally vertex-disjoint.
Similarly, for any edge , let be the enumerating polynomial of all all pairs such that
-
1.
, and
-
2.
Prefix and suffix are internally vertex-disjoint.
The next two lemmas present relations between the polynomials , and , using a reasoning similar to those in Lemma 33 of [3] for solving 2-DSP in DAGs.
Lemma 4.1.
For any satisfying , for , we have
Proof.
Consider a pair of shortest paths contributing to . For , decompose , where and are shortest paths. Then,
Thus, enumerates all such tuples of shortest paths satisfying the following.
-
For each , is an -shortest path and is a -shortest path.
-
The paths and are internally vertex-disjoint.
The contribution of all such internally disjoint path pairs is captured by the polynomial . Meanwhile, the contributions of the unconstrained paths and , which are only required to be shortest paths between their endpoints, are given by and , respectively. Multiplying these three components yields the desired expression.
Lemma 4.2.
For any , satisfying , for , we have
Proof.
Consider a pair of shortest paths contributing to . For , decompose each , where and are shortest paths. Then,
Thus, enumerates all such tuples of shortest paths satisfying the following.
-
For each , is an -shortest path and is a -shortest path.
-
The paths and are internally vertex-disjoint.
The contribution of all such internally disjoint path pairs is captured by the polynomial . Meanwhile, the contributions of the unconstrained paths and , which are only required to be shortest paths between their endpoints, are given by and , respectively. Multiplying these components together, along with the term, yields the desired expression.
II. Paths with First Intersection at a Given Vertex along a Reference Path
We define to be the enumerating polynomial of the collection of pairs whose first intersection point with respect to is vertex .222Note that may not be the first/last intersection point with respect to path . More formally, the paths and satisfy the following.
-
1.
, and
-
2.
Prefix is internally vertex-disjoint with as well as .
It is important to observe that if , then will be a zero polynomial. We next present a relation between polynomials and . The lemma below crucially uses the fact that the underlying field has characteristic two.
Lemma 4.3.
For any satisfying for , we have
Proof.
Let be a collection of all pairs of paths such that
-
1.
,
-
2.
prefix and suffix are internally vertex-disjoint, and
-
3.
if and are the vertices preceding in and respectively (assuming these vertices exist, otherwise this condition holds vacuously), then .
The definitions of the polynomials and imply that the enumerating polynomial for the pairs in is given by
Let be the set of all pairs of paths contributing to . In order to prove the claim it suffices to prove that the enumerating polynomials of and are identical (mod 2). First, observe that . Indeed, if , then is internally vertex-disjoint from both and , which in particular ensures that the in-edges of in and (if they exist) must be distinct.
Now consider any pair . The definitions of and imply that the following two conditions must hold: (i) the sub-paths and have a common internal vertex, (ii) the edges preceding in these two sub-paths respectively are distinct. Let be the immediate predecessor of common to both the paths. It follows that is a twin-crossing pair for . Let . ˜2.8 shows that has as twin-crossing pair and hence lie in (see Figure 3). Further, it follows that must be the immediate predecessor of on and .
Thus, the set can be partitioned into pairs where and is the immediate predecessor of on (as well as, on ). Since , we see that each such pair contributes two identical monomials to the enumerating polynomial of . Thus, the total contribution of is a multiple of two, and hence zero in a field of characteristic two. This establishes the claim.
III. Intersecting and Disjoint Shortest paths
We define to be the enumerating polynomial for all pairs of shortest paths between pairs and that are not internally vertex-disjoint. Observe that
Indeed, if two paths are intersecting (at an internal vertex), there must exist a unique earliest intersection point on (that lies outside the set ). Since every pair of and shortest paths is either internally vertex-disjoint or else intersects at some common vertex outside the set , we obtain the following result.
Lemma 4.4.
The enumerating polynomial is given by
4.2 Solving 2-DSP in time
In this subsection, we present an algorithm for solving the 2-DSP problem in weighted directed graphs that takes time. Let and be the input terminal pairs. By Schwartz-Zippel lemma (Lemma 2.4), in order to check if is non-zero it suffices to evaluate this polynomial on a random assignment of the variables drawn from a sufficiently large finite field . The algorithm for evaluating at these random values is given in Algorithm 1.
We begin by assigning random values from to each of the edge variables respectively. For a polynomial involving the variables , we shall use to denote the value in obtained by evaluating at . Using Lemma 2.6, we compute for all pairs of vertices in time. In order to compute we would need to compute for several tuples . We store all such tuples in a list . In particular, contains the following: (i) tuples , for each ; (ii) tuples , for each ; and (iii) the query tuple .
Now we evaluate for each such tuple in using dynamic programming. For this, we define a partial order on the set of vertices of the graph as follows: for any distinct , we say if there exists an -to- shortest path in that contains (as an internal vertex). This is well-defined, as contains no cycles of zero or negative weight.
Definition 4.5.
Given the partial order on , let denote an ordered list such that tuples of the form , precede tuples like , whenever , i.e., whenever lies on an shortest path. The tuple appears at the end of the list.
Computing for tuples in the order given by ensures that that while evaluating , all the values that are required for this computation are available. In the base case, when and , we set .
To evaluate , we use the identity (see Lemma 4.4):
By Lemma 4.3 , can be expressed as
for each . Now, by Lemma 4.1, we have
We shall show in Lemma 4.6 (for proof refer to the full version [11]) that the ordering induced by ensures that the right-hand side above has already been computed by the dynamic program. Similarly, by Lemma 4.2, for any edge ,
Finally, we output that there exists two disjoint shortest paths between and if and only if evaluates to non-zero.
Lemma 4.6.
We can compute in time the ordered list so that, when invoking pairs according to this ordering in our dynamic program, all subproblems required are already computed.
Correctness and Running Time.
The correctness of the procedure follows from the recursive expressions in Lemma 4.1, Lemma 4.2, Lemma 4.3, and Lemma 4.4. We now analyze the running time. First observe that has tuples: there are at most choices for the tuples and at most choices for . The description of the algorithm shows that we can evaluate in time for any fixed , and hence we can compute in total time per quadruple. Since we evaluate these polynomials for quadruples in , the overall running time is bounded by , after an initial preprocessing step of . This yields a randomized -time algorithm for 2-DSP with high success probability.
4.3 An time algorithm for 2-DSP
We now present an improved algorithm for solving the 2-DSP problem in time. Recall from the previous subsection that Algorithm 1 computes by evaluating for all quadruples in a list of size , where each evaluation incurs time. Note that we can afford time computation for evaluating for each – since there are only such vertices, this would incur a total of time. Therefore, our focus will be on improving the computation of , where is an edge in .
Consider a vertex . We show how to compute , for all relevant edges in total time.
Let be such that . Now, Lemma 4.4 shows that computation of requires us to evaluate for each (see Figure 4). Now, line 8 in Algorithm 1 shows that
The last inequality holds because , for any . Specifically, (i) if , then by the substructure property of shortest paths; (ii) conversely, if and lies on an -shortest path , then , since the prefix of up to can be replaced by an -shortest path passing through . We emphasize that the sum in the parenthesis above depends only on and , and not on the specific choice of . Hence, we can pre-evaluate this expression once per in time and reuse it for all relevant in-neighbors of . Since , the total time across all such computations for a fixed vertex is .
Summing over all gives a total time of to evaluate all required instances of .
Finally, using Lemma 2.6, we can evaluate all values in time. Hence, the overall running time of our improved algorithm for detecting two disjoint shortest paths becomes . Thus, we can conclude with the following theorem.
Theorem 4.7.
The 2-DSP problem in directed weighted graphs having no cycles of negative or zero weight is solvable in time.
4.4 Reporting the Paths
We now show how to compute a pair of internally vertex-disjoint shortest paths from to and from to in -time, if such paths exist.
Recall that the proof of Theorem 4.7 provides an time algorithm for solving the -DSP problem for a collection of quadruples lying in a list . In order to report the paths, we show how to compute an out-neighbor of that appears in some solution to the -DSP problem in the same time bound. Recall that the list comprises of (i) tuples , for each ; (ii) tuples , for each ; and (iii) the query tuple .
To compute the out-neighbor of , we remove the tuple from list , and append the tuples , for . Now, we can solve the -DSP problem for all pairs in in the graph , in the same time bound of . By Schwartz-Zippel lemma (Lemma 2.4), with high probability, the out-neighbors of that participates in solution to the -DSP problem are precisely those for which evaluates to non-zero in the graph . After finding the node , we delete vertex from , and consider a smaller instance of the -DSP problem, where source is replaced with . This process is repeated at most times, helping us recover an -shortest path , disjoint from some -shortest path in .
Finally, we delete the vertices of from , and find an -shortest path in the resulting graph in time using the Bellman-Ford algorithm. This provides us an algorithm for reporting a pair of disjoint and shortest paths, if they exists, in time.
Theorem 4.7 together with discussion above proves the following result.
Theorem 1.1. [Restated, see original statement.]
The 2-DSP problem in directed weighted graphs having no cycles of negative or zero weight is solvable in time. Moreover, we can report the explicit paths, if they exist, in time.
5 Min-2-DSP in Directed graphs
In this section, we consider the Min-2-DSP problem in directed graphs with positive edge weights and show that it can be solved in time. For any vertex pairs and , and any integer , let be the enumerating polynomial of all pairs of shortest paths from to and from to such that the interaction complexity
is at most . In order to solve Min-2-DSP it suffices to determine the smallest integer for which polynomial is non-zero, where and are input source-destination pairs.
For any vertex pairs and , any integer , and vertices , define
to be the enumerating polynomial of all pairs , having interaction complexity at most and such that is the first (with respect to ) concordant pair in .
The following lemma provides relation between polynomials and .
Lemma 5.1.
Let and be pairs satisfying the property that any pair of paths intersect internally. Then, for any integer , we have
Proof.
Let be a pair of paths with interaction complexity . Furthermore, let be the first concordant pair appearing on . Then, the enumerating polynomial for such pairs is given by . To obtain , we sum over all choices of concordant pairs. This proves the desired claim. To efficiently determine whether is a non-zero polynomial, we define next some helper polynomials.
5.1 Additional Helper Polynomials
For any vertex pairs and , any integer , and any , define
to be the enumerating polynomial for all pairs of shortest paths between and such that:
-
1.
the subpaths and are internally vertex-disjoint; and
-
2.
the interaction complexity of and is at most .
Similarly, we define the polynomials , , and , which satisfy the above constraints with the additional requirement that the paths must contain the edges , , and both and , respectively.
Note that in the definitions of , , , and any in-neighbor of or out-neighbor of that appears in both and is not counted in the overlap budget as the overlap constraint in condition two applies exclusively to the number of common vertices between the suffix of starting from and prefix of up to .
5.2 Properties of Helper Polynomials
We first present a relation between and polynomials , , , and (for proof see the full version [11]).
Lemma 5.2.
For any quadruple , integer , and any such that precedes on some and shortest paths, the following holds:
Next we provide construction of other helper polynomials.
Lemma 5.3.
For any integer , and any such that precedes on some and shortest paths, the following holds:
Proof.
Consider a pair of shortest paths contributing to . For , decompose , where , , and are shortest paths. The definition of , together with the observation that and coincide at a minimum of vertices, implies that the interaction complexity of is bounded above by . The contributions of the paths and is captured by . Meanwhile, the contribution of all the internally disjoint path pairs is given by the polynomial . Finally, observe that the contribution of is given by since if , then the pair will have the same monomial contribution as that of , which will cancel modulo . Multiplying these components yields the desired expression.
Similar to the above lemma, we can establish the following.
Lemma 5.4.
For any integer , and any , such that precedes on some and shortest paths, the following holds:
Lemma 5.5.
For any integer , and any , such that precedes on some and shortest paths, the following holds:
Lemma 5.6.
For any integer , and any such that precedes on some and shortest paths, the following holds:
5.3 An time algorithm for Min-2-DSP
In this subsection, we present an algorithm for solving the Min-2-DSP problem in weighted directed graphs that takes time. Let and be the input terminal pairs. By Schwartz-Zippel lemma (Lemma 2.4), in order to check if is non-zero it suffices to evaluate this polynomial on a random assignment of the variables drawn from a sufficiently large finite field . The algorithm outputs the smallest integer for which evaluates to non-zero at a random assignment of edge variables.
We begin by assigning random values from to each of the edge variables respectively. As before, for a polynomial involving the variables , we shall use to denote the value in obtained by evaluating at . Using Lemma 2.6, we compute for all pairs of vertices in time, and, in addition, we compute for all vertex-pairs using the dominator-tree algorithm of Lengauer and Tarjan [17, 15].
We next evaluate the polynomial , for each quadruple , in total time. This is accomplished by leveraging a dynamic programming approach similar to Algorithm 1. We process the quadruples in the non-decreasing order of the sum total distance between the endpoints (i.e., ).
At each step, we use recurrence identities established in Lemmas 4.1, 4.2, 4.3, and 4.4. For a fixed , we compute for each valid in time, and combine them to evaluate in time. This yields an overall runtime of . See the detailed in the full version [11].
In order to compute we would need to evaluate for several values of tuples and integers . We compute a list containing tuples of the form for all . For each such tuple in , we evaluate using dynamic programming. These computations are performed in the non-decreasing order of the sum total distance between the endpoints, i.e., , which ensures that all necessary values for the recurrence are available when needed. For base cases, when either or , the values simplify as follows:
-
1.
, and
-
2.
.
To evaluate , we use the identity (see Lemma 5.1):
By Lemma 5.2, for any and any satisfying , for , can be expressed as
Now, by Lemmas 5.3, 5.4, 5.5, and 5.6, we have
Note that and hence, the right-hand side has been computed already. Finally, we return the smallest integer for which evaluates to non-zero. See the detailed algorithm in the full version [11].
Correctness and Running Time.
The correctness of the procedure follows from the recursive expressions in Lemmas 5.1, 5.2, 5.3, 5.4, 5.5, and 5.6.
We now analyze the running time. From the identities above, observe that each polynomial can be evaluated in time for any fixed , and integer . Consequently, we can compute in time for any fixed quadruple and any fixed . Since we evaluate these polynomials for such quadruples in the set and for distinct values of , the total evaluation time is bounded by . The algorithm has an initial preprocessing phase, where we first solve All-Pairs 2-DSP in time, and then compute the number of distance-critical vertices for all pairs in time. The latter uses the dominator-tree algorithm of Lengauer and Tarjan [17, 15], which identifies all cut vertices for pairs in in time per source. Altogether, this yields a randomized algorithm for Min-2-DSP with a total running time of and high success probability.
The details of our procedure for reporting the actual and shortest paths with minimum intersection are deferred to the full version, as it is closely related to the procedure outlined in Section 4.4. We conclude with the following theorem.
Theorem 1.2. [Restated, see original statement.]
The Min-2-DSP problem in directed graphs with positive edge weights is solvable in time. Moreover, we can report the explicit paths in time bound.
6 Open Problems
Our work, together with recent advances on the 2-Disjoint Shortest Paths problem [4, 6, 7], opens up a plethora of exciting new directions for the 2-DSP problem (see also Section 8.7 of [2] for further related open problems). A first challenge is to improve upon the current time algorithm for 2-DSP on general directed graphs? If not, can one obtain conditional lower bounds ruling out such improvements?
Open Problem 6.1.
Is it possible to solve 2-DSP in time on general directed weighted graphs with no cycles of negative or zero weight? If not, can one prove fine-grained lower bounds ruling out such an improvement?
It is important to note that due to the algebraic nature of the results of [4] and our work, the time complexities primarily discussed are for detecting the existence of disjoint shortest paths. Returning an explicit pair of such paths, when they exist, incurs an additional multiplicative factor of in the running time [4]. An interesting question to answer is whether the two disjoint shortest paths can be reported in the same time as detecting such paths.
Open Problem 6.2 ([4]).
In DAGs and undirected graphs, does there exist an time algorithm to report the two disjoint shortest paths, if they exist? For general directed graphs, does there exist an algorithm to report such paths?
Due to recent breakthroughs of [6, 18], it has been established that for any constant , -DSP can be solved in polynomial time in undirected graphs. It is not too hard to obtain such guarantees for DAGs either [4, 7, 13]. However, for general directed graphs, it is not even known whether 3-DSP can be solved in polynomial time (no hardness results are known either). Hence, it is worthwhile to ask if our techniques can be used to obtain an efficient algorithm for 3-DSP.
Open Problem 6.3.
In general directed graphs, can 3-DSP be solved in polynomial time? Alternatively, can one establish meaningful hardness results for 3-DSP in this setting?
Another promising direction is to extend the -DSP to the newly introduced Min-2-DSP problem. In particular, can one solve Min--DSP in undirected graphs in polynomial time for every constant ? An affirmative answer would yield a natural counterpart to the existing -DSP results on undirected graphs, whereas a negative answer would provide an interesting separation between the -DSP and Min--DSP problems.
Open Problem 6.4.
In undirected graphs, can Min--DSP be solved in polynomial time for every fixed ? Alternatively, can one prove hardness results for Min--DSP in this regime?
Lastly, the algebraic algorithms described in [4] and this work inherently make use of randomization, as they invoke the Schwartz-Zippel lemma. It be would be interesting to obtain deterministic algorithms for 2-DSP and Min-2-DSP, with running time comparable to the randomized algorithms of [4] and this work. We believe this will provide us with deeper structural insights into the problems.
Open Problem 6.5.
Can one obtain deterministic algorithms for 2-DSP and Min-2-DSP, which match the time bounds guaranteed by the current fastest randomized algorithms?
References
- [1] Maxim Akhmedov. Faster 2-disjoint-shortest-paths algorithm. In Henning Fernau, editor, Computer Science - Theory and Applications - 15th International Computer Science Symposium in Russia, CSR 2020, Yekaterinburg, Russia, June 29 - July 3, 2020, Proceedings, volume 12159 of Lecture Notes in Computer Science, pages 103–116. Springer, 2020. doi:10.1007/978-3-030-50026-9_7.
- [2] Shyan Akmal. Parameterized Relaxations for Circuits and Graphs. Ph.d. thesis, Massachusetts Institute of Technology, Cambridge, MA, May 2024. URL: https://dspace.mit.edu/handle/1721.1/156299.
- [3] Shyan Akmal, Virginia Vassilevska Williams, and Nicole Wein. Detecting disjoint shortest paths in linear time and more. CoRR, abs/2404.15916, 2024. doi:10.48550/arXiv.2404.15916.
- [4] Shyan Akmal, Virginia Vassilevska Williams, and Nicole Wein. Detecting Disjoint Shortest Paths in Linear Time and More. In Karl Bringmann, Martin Grohe, Gabriele Puppis, and Ola Svensson, editors, 51st International Colloquium on Automata, Languages, and Programming (ICALP 2024), volume 297 of Leibniz International Proceedings in Informatics (LIPIcs), pages 9:1–9:17, Dagstuhl, Germany, 2024. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ICALP.2024.9.
- [5] Matthias Bentert, Fedor V. Fomin, and Petr A. Golovach. Tight Approximation and Kernelization Bounds for Vertex-Disjoint Shortest Paths. In Olaf Beyersdorff, Michał Pilipczuk, Elaine Pimentel, and Nguyen Kim Thang, editors, 42nd International Symposium on Theoretical Aspects of Computer Science (STACS 2025), volume 327 of Leibniz International Proceedings in Informatics (LIPIcs), pages 17:1–17:17, Dagstuhl, Germany, 2025. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.STACS.2025.17.
- [6] Matthias Bentert, André Nichterlein, Malte Renken, and Philipp Zschoche. Using a geometric lens to find k disjoint shortest paths. In Nikhil Bansal, Emanuela Merelli, and James Worrell, editors, 48th International Colloquium on Automata, Languages, and Programming, ICALP 2021, July 12-16, 2021, Glasgow, Scotland (Virtual Conference), volume 198 of LIPIcs, pages 26:1–26:14. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021. doi:10.4230/LIPIcs.ICALP.2021.26.
- [7] Kristof Berczi and Yusuke Kobayashi. The Directed Disjoint Shortest Paths Problem. In Kirk Pruhs and Christian Sohler, editors, 25th Annual European Symposium on Algorithms (ESA 2017), volume 87 of Leibniz International Proceedings in Informatics (LIPIcs), pages 13:1–13:13, Dagstuhl, Germany, 2017. Schloss Dagstuhl – Leibniz-Zentrum für Informatik. doi:10.4230/LIPIcs.ESA.2017.13.
- [8] Andreas Björklund and Thore Husfeldt. Shortest two disjoint paths in polynomial time. In Javier Esparza, Pierre Fraigniaud, Thore Husfeldt, and Elias Koutsoupias, editors, Automata, Languages, and Programming, pages 211–222, Berlin, Heidelberg, 2014. Springer Berlin Heidelberg. doi:10.1007/978-3-662-43948-7_18.
- [9] Andreas Björklund, Thore Husfeldt, and Petteri Kaski. The shortest even cycle problem is tractable. In Stefano Leonardi and Anupam Gupta, editors, STOC ’22: 54th Annual ACM SIGACT Symposium on Theory of Computing, Rome, Italy, June 20 - 24, 2022, pages 117–130. ACM, 2022. doi:10.1145/3519935.3520030.
- [10] Rajesh Chitnis, Samuel Thomas, and Anthony Wirth. Lower bounds for approximate (& exact) k-disjoint-shortest-paths, 2024. doi:10.48550/arXiv.2408.03933.
- [11] Keerti Choudhary, Amit Kumar, and Lakshay Saggi. Efficient algorithms for disjoint shortest paths problem and its extensions, 2025. doi:10.48550/arXiv.2509.14588.
- [12] Tali Eilam-Tzoreff. The disjoint shortest paths problem. Discrete Applied Mathematics, 85(2):113–138, June 1998. doi:10.1016/s0166-218x(97)00121-2.
- [13] Steven Fortune, John E. Hopcroft, and James Wyllie. The directed subgraph homeomorphism problem. Theoretical Computer Science, 10(2):111–121, 1980. doi:10.1016/0304-3975(80)90003-9.
- [14] Ryo Funayama, Yasuaki Kobayashi, and Takeaki Uno. Parameterized complexity of finding dissimilar shortest paths, 2024. doi:10.48550/arXiv.2402.14376.
- [15] Loukas Georgiadis and Robert Endre Tarjan. Dominator tree verification and vertex-disjoint paths. In Proceedings of the Sixteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2005, Vancouver, British Columbia, Canada, January 23-25, 2005, pages 433–442. SIAM, 2005. URL: http://dl.acm.org/citation.cfm?id=1070432.1070492.
- [16] Donald B. Johnson. Efficient algorithms for shortest paths in sparse networks. J. ACM, 24(1):1–13, January 1977. doi:10.1145/321992.321993.
- [17] Thomas Lengauer and Robert Endre Tarjan. A fast algorithm for finding dominators in a flowgraph. ACM Trans. Program. Lang. Syst., 1(1):121–141, 1979. doi:10.1145/357062.357071.
- [18] William Lochet. A polynomial time algorithm for the k-disjoint shortest paths problem. In Dániel Marx, editor, Proceedings of the 2021 ACM-SIAM Symposium on Discrete Algorithms, SODA 2021, Virtual Conference, January 10 - 13, 2021, pages 169–178. SIAM, 2021. doi:10.1137/1.9781611976465.12.
- [19] Mathieu Mari, Anish Mukherjee, Michał Pilipczuk, and Piotr Sankowski. Shortest Disjoint Paths on a Grid, pages 346–365. SIAM, 2024. doi:10.1137/1.9781611977912.14.
- [20] R.G. Ogier, V. Rutenburg, and N. Shacham. Distributed algorithms for computing shortest pairs of disjoint paths. IEEE Transactions on Information Theory, 39(2):443–455, 1993. doi:10.1109/18.212275.
- [21] Michał Pilipczuk, Giannos Stamoulis, and Michał Włodarczyk. Planar disjoint shortest paths is fixed-parameter tractable, 2025. doi:10.48550/arXiv.2505.03353.
- [22] Anand Srinivas and Eytan Modiano. Finding minimum energy disjoint paths in wireless ad-hoc networks. Wireless Networks, 11(4):401–417, July 2005. doi:10.1007/s11276-005-1765-0.
- [23] Clark David Thompson. A complexity theory for VLSI. PhD thesis, Carnegie Mellon University, USA, 1980. AAI8100621.
