arXiv:2611.05311cs.DSNov 2026

Manuscript Offprint

arXiv:2611.05311

Roundtrip All-Pairs Shortest Paths in Directed Graphs

Shiri Chechik, Gur Lifshitz

Abstract

We study approximation algorithms for All-Pairs Shortest Paths (APSP) in directed graphs under the roundtrip metric. In undirected graphs, approximate APSP has been studied extensively, yielding a rich landscape of tradeoffs between approximation stretch and running time, from the classical O(mn)O(mn) exact algorithm toward the Ω(n2)\Omega(n^2) output-size barrier. In directed graphs, however, even finite-factor approximation of ordinary one-way distances must distinguish reachable from unreachable vertex pairs, and therefore computes transitive closure, a problem equivalent to Boolean matrix multiplication (BMM) under standard reductions. The roundtrip distance, defined as distG(u↭v)=distG(u→v)+distG(v→u)\text{dist}_G(u \leftrightsquigarrow v) = \text{dist}_G(u \to v) + \text{dist}_G(v \to u), offers a natural and robust relaxation. It measures the cost of traveling from uu to vv and back, satisfies the triangle inequality, and is inherently symmetric. While this metric has become central to the study of directed roundtrip spanners and compact routing, the fundamental problem of all-pairs roundtrip distance approximation has remained largely unexplored. In this work, we present a comprehensive study of roundtrip APSP and distance oracles, presenting several new lower and upper bounds. On the algorithmic side, our main result is a combinatorial algorithm that computes a stretch-3 approximation to all-pairs roundtrip distances in O~(n2+min⁡{mn,m1/3n5/3})\widetilde{O}(n^2 + \min\{m\sqrt{n}, m^{1/3}n^{5/3}\}) time. For edge weights in [1,W][1, W], we also obtain a (3+ε)(3+\varepsilon)-approximation in O~((n2.037+nm2/3)log⁡(nW)/ε)\widetilde{O}((n^{2.037} + nm^{2/3})\log(nW)/\varepsilon) time and a (4+ε)(4+\varepsilon)-approximation in O~(n2.032log⁡(nW)/ε)\widetilde{O}(n^{2.032}\log(nW)/\varepsilon) time using fast matrix multiplication. On the hardness side, we show that any stretch below 3 would imply a breakthrough for BMM. We also obtain additional tradeoffs between stretch and running time.

1 Introduction

The All-Pairs Shortest Paths (APSP) problem is one of the most fundamental problems in graph algorithms. Given a graph G=(V,E,w)G = (V, E, w) with nonnegative edge weights, the goal is to compute the shortest-path distance between every ordered pair of vertices. For dense graphs with real nonnegative edge weights, the classical algorithm of Floyd–Warshall [1] runs in O(n3)O(n^3) time, and the fastest known exact algorithms improve over this bound only by no(1)n^{o(1)} factors (see [2]). A central hypothesis in fine-grained complexity asserts that no O(n3−ε)O(n^{3-\varepsilon})-time algorithm can solve APSP in edge-weighted graphs, for any fixed ε>0\varepsilon > 0 (see [3]). Consequently, most progress toward faster algorithms has relied on either approximation techniques, or algebraic methods such as fast matrix multiplication combined with restrictions on the edge weights.

*Tel Aviv University, Israel. E-mail: shiri.chechik@gmail.com, gurlifshitz@gmail.com.

Approximating Undirected APSP The study of approximate APSP in undirected graphs dates back to the late 1990s. In unweighted graphs, Aingworth et al. [4] gave a combinatorial +2-approximation in O~(n5/2)\widetilde{O}(n^{5/2}) time, and Dor, Halperin, and Zwick [5] improved the running time to O~(min⁡{n3/2m1/2,n7/3})1\widetilde{O}(\min\{n^{3/2}m^{1/2}, n^{7/3}\})^{1}. Roditty [6] gave a combinatorial stretch-2 algorithm in O~(n9/4)\widetilde{O}(n^{9/4}) time, and Dory et al. [7] and independently Saha and Ye [8] obtained an algebraic stretch-2 algorithm in O(n2.0329)O(n^{2.0329}) time. For weighted graphs, Cohen and Zwick [9] established the classical tradeoffs, including stretch 3 in near-quadratic time, stretch 7/3 in O~(n7/3)\widetilde{O}(n^{7/3}) time, and stretch 2 in O~(n3/2m1/2)\widetilde{O}(n^{3/2}m^{1/2}) time. Baswana and Kavitha [10] obtained a combinatorial stretch-2 algorithm running in O~(n2+mn)\widetilde{O}(n^{2}+m\sqrt{n}) time. Further combinatorial and algebraic tradeoffs for weighted and unweighted graphs can be found in, e.g., [11, 12, 13, 14].

Approximating Directed APSP The directed case is substantially less understood. For exact APSP with small integer weights, Alon, Galil, and Margalit [15] gave an O(n(ω+3)/2)O(n^{(\omega+3)/2})-time algorithm, and Zwick [16] later improved this to O(n2.575)O(n^{2.575}) using rectangular matrix multiplication; this remains the fastest known exact bound even for unweighted directed graphs. Zwick also showed that, for polynomially bounded weights, a (1+ε)(1+\varepsilon)-approximation can be computed in O~(nω/ε)\widetilde{O}(n^{\omega}/\varepsilon) time. Roditty and Shapira [17] later obtained algebraic additive-error tradeoffs, achieving additive error dG(u,v)pd_G(u,v)^p in time O(n2.575−p7.4−2.3p)O\left(n^{2.575-\frac{p}{7.4-2.3p}}\right) for every 0≤p≤10\leq p\leq 1.

Any multiplicative approximation to directed distances must distinguish finite from infinite distances, and therefore computes transitive closure. Since transitive closure and Boolean matrix multiplication are equivalent under standard reductions [18, 19], such an approximation algorithm would also yield an algorithm for Boolean matrix multiplication with essentially the same running time. This motivates studying the roundtrip metric.

Roundtrip Distances A central concept in the analysis of directed graphs is the roundtrip distance, introduced by Cowen and Wagner [20]. This metric is motivated by the observation that two vertices are often meaningfully close only if one can travel from one to the other and back at small total cost. For vertices u,v∈V(G)u,v\in V(G), the roundtrip distance is defined as

distG(u⟺v)=distG(u→v)+distG(v→u),\mathrm{dist}_{G}(u\Longleftrightarrow v)=\mathrm{dist}_{G}(u\to v)+\mathrm{dist}_{G}(v\to u),

that is, the total length of the shortest directed closed walk passing through both uu and vv. This measure is symmetric and satisfies the triangle inequality, inducing a metric on every strongly connected component of GG.

One way to view this metric is through the complete undirected graph GrtG^{\mathrm{rt}} on the vertex set VV, where the edge {u,v}\{u,v\} has weight distG(u⟺v)\mathrm{dist}_{G}(u\Longleftrightarrow v). The difficulty is that GrtG^{\mathrm{rt}} is dense and implicit: computing its edge weights exactly is essentially the directed APSP problem. Thus, the challenge is to exploit the undirected metric structure of roundtrip distances without explicitly constructing the metric.

The roundtrip metric has played a central role in directed spanners and routing. Roditty, Thorup, and Zwick [21] initiated the study of roundtrip spanners for directed graphs, showing general (2k+ε)(2k+\varepsilon)-roundtrip spanners with O~ε(kn1+1/k)\widetilde{O}_{\varepsilon}(kn^{1+1/k}) edges, extending these constructions to compact roundtrip routing schemes, and proving that every weighted directed graph admits an optimal-size

1^{1}The O~(⋅)\widetilde{O}(\cdot) notation hides polylogarithmic factors in nn.

3-roundtrip spanner with O(n3/2)O(n^{3/2}) edges. Later work developed faster constructions of roundtrip spanners and closely related algorithms for directed-girth approximation.

Chechik, Liu, Rotem, and Sidford [22] were the first to obtain a constant-factor approximation for the directed girth in subquadratic time, achieving a 3-approximation in O~(mn)\tilde{O}(m\sqrt{n}) time. Using closely related techniques, they also showed how to construct an 8-roundtrip spanner with O~(n3/2)\tilde{O}(n^{3/2}) edges in the same running time.

Dalirrooyfard and Vassilevska Williams [23] subsequently obtained a (2+ε)(2+\varepsilon)-approximation for weighted directed girth in O~(mn)\tilde{O}(m\sqrt{n}) time, together with a (5+ε)(5+\varepsilon)-roundtrip spanner with O~(n3/2)\tilde{O}(n^{3/2}) edges in the same running time.

Building on this line of work, Chechik and Lifshitz [24] gave a 2-approximation for the girth in O~(mn)\tilde{O}(m\sqrt{n}) time. They also presented a different algorithm that computes both a 2-approximation for the girth and a 4-roundtrip spanner with O~(n3/2)\tilde{O}(n^{3/2}) edges in O~(n2)\tilde{O}(n^2) time. More recently, Harbuzova, Jin, Vassilevska Williams, and Xu [25] further extended these ideas to obtain a 3-roundtrip spanner with O(n3/2)O(n^{3/2}) edges in O~(mn)\tilde{O}(m\sqrt{n}) time. The roundtrip metric has also found applications in compact routing and more roundtrip spanner constructions; see, e.g., [21, 26, 27].

Lower Bounds. For directed girth, Dalirrooyfard and Vassilevska Williams [23] showed that, under the kk-Cycle Hypothesis, no O(m2−ε)O(m^{2-\varepsilon})-time algorithm can achieve a (2−δ)(2-\delta)-approximation, for any constants ε,δ>0\varepsilon, \delta > 0.