Manuscript Offprint
arXiv:2611.01297Reading between the levels: new tools for the Thorup-Zwick hierarchy and their applications
Abstract
In this paper, we develop three new analytical tools for the Thorup-Zwick hierarchy: the Mixed-Level Growth, Two-Level Growth, and Long-Short Growth lemmas. Using these tools, we obtain improved approximate distance oracles (ADOs), and algorithms for -pairs shortest paths (-PSP), multiple-source shortest paths (MSSP), and -shortest paths, as well as new hopsets.
One of our main results is a -stretch ADO with preprocessing time and space (where hides polylogarithmic factors), and query time, breaking, for sparse graphs, the -stretch barrier for ADOs with space and query time. In unweighted graphs, we also obtain a -approximate ADO with space and query time.
This also yields a -approximation algorithm for -pairs shortest paths (-PSP) in time, answering the question of Chechik, Hoch, and Lifshitz [SODA'25] of whether the barrier for -PSP in time can be broken.
For unweighted graphs, we give a new analysis of the existing -time -PSP algorithm of [Chechik et al., SODA'25], and show that, without any modification, it is a -approximation, i.e., for every queried pair. This improves its multiplicative factor from to , and the leading coefficient is tight for this algorithm. Moreover, for graphs with , this answers the question of Dalirrooyfard et al. [FOCS'22] up to the additive .
*Department of Computer Science, Tel Aviv University, Israel. E-mail shiri.chechik@gmail.com. †Department of Computer Science, Tel Aviv University, Israel. E-mail gur.lifshitz@gmail.com. ‡Department of Computer Science, Bar-Ilan University, Ramat Gan 5290002, Israel. E-mail avi.kadria3@gmail.com. §Department of Computer Science, Bar-Ilan University, Ramat Gan 5290002, Israel. E-mail liam.roditty@biu.ac.il. Supported in part by BSF grants 2016365 and 2020356.
1 Introduction
In their seminal work, Thorup and Zwick [TZ05] introduced an approximate distance oracle (ADO) based on a hierarchical graph decomposition. Let be an undirected graph with vertices and edges. An ADO is a data structure that, given a pair of vertices , returns an estimate of the distance between them. An ADO has stretch if for every pair of vertices , and it is an -approximation if . For every integer , the Thorup-Zwick ADO has stretch , uses space, answers queries in time, and is constructed in time.
The Thorup–Zwick hierarchy and related techniques have found applications in many graph algorithms and data structures, including ADOs [RTZ05, Wul12, Wul13, Che14, Che15, ENW16, KR25b, KR26a, CZ22], girth and shortest-cycle approximation [KRS+22, HJWX24, KRS+26, KRV26b, Kad26], diameter approximation [CGR16, KRQV26], spanners and emulators [TZ06, BS07, Pet09, HJWX24], APSP approximations [Elk05, BK10, AR20, CZ22, Rod23, DFK+24, AR21, RS25], compact routing [TZ01, Che13, KR25a], distance labeling [AG11, DSDP15, EFN18], and hopsets [HP19, BP20, EN22, NS22].
Our main contributions are three new analytical tools for the Thorup-Zwick hierarchy: the Mixed-Level Growth, Two-Level Growth, and Long-Short Growth lemmas. Using these tools, we obtain new algorithms for a variety of fundamental distance problems, improving upon the state of the art for each of them. We outline the main ideas behind these tools in Section 3.
Next, we describe our contributions for each problem and compare them with previous work. Throughout the paper, k denotes a positive integer parameter. All of these results are direct applications of the new tools, and we believe that the tools can be used to improve algorithms for other graph problems as well.
ADOs with nonconstant query time. To improve upon the -stretch of the Thorup-Zwick ADO in weighted graphs, a common approach is to allow a larger query time and to focus on sparse graphs. ADOs with nonconstant query time have been studied in both weighted and unweighted graphs [AGH11, PR13, AGH12, AG13, PR14, Aga14, DJWW22, KR25b].
We first discuss weighted graphs. Agarwal, Godfrey, and Har-Peled [AGH11] were the first to study this regime. They obtained a -stretch ADO with space and query time, constructed in time. Later, Kadria and Roditty [KR25b] improved the stretch to 2k-5 with the same space and query time, at the cost of an increased construction time of . These results left open whether the 2k-O(1) stretch barrier could be broken:
Question 1. Is there an ADO for sparse weighted graphs (with ) that uses space and query time, and has stretch for some constant ?
The barrier has a common source. In the Thorup-Zwick query, every level at which the search fails to connect and allows the pivot distance to grow by up to . The estimate therefore grows by per level, which gives stretch after levels. All previous ADOs with query time, as well as all previous -time -PSP algorithms, improve this analysis only at the first one or two levels. At every other level, they still pay the full of Thorup and Zwick [TZ05]. Hence, their savings are additive, and their stretch remains . Our tools limit the growth of the pivot distances at every level of the hierarchy. The savings thus accumulate over all levels, which reduces the leading coefficient of the stretch and breaks the barrier.
We answer Question 1 in the affirmative and break the stretch barrier by obtaining a -stretch ADO with query time, and space and preprocessing time.
Theorem 1 (ADO-weighted). There is an -time algorithm that constructs a -stretch ADO for weighted undirected graphs, with space and query time.
The notation suppresses polylogarithmic factors in . Since for , we assume that , so also suppresses factors polynomial in .
Assuming the Erdős girth conjecture, the lower bound of Thorup and Zwick [TZ05] rules out stretch below with space in general graphs, regardless of query time.
| Graphs | Reference | Preprocessing | Space | Query | Approximation |
|---|---|---|---|---|---|
| Weighted | [TZ05] | ||||
| [DJWW22] | |||||
| [AGH11] | |||||
| [KR25b] | |||||
| Theorem 1 | |||||
| Unweighted | [TZ05] | ||||
| [DJWW22] | |||||
| [AGH11] | |||||
| [KR25b] | |||||
| Theorem 2 |
Table 1: ADOs with nonconstant query time.
In unweighted graphs, allowing an additive error removes the dependence on from the space and query time. Here, the state of the art is the -approximate ADO of Kadria and Roditty [KR25b], with space, query time, and preprocessing time. The main question is whether the barrier can be broken:
Question 2. Is there an ADO for unweighted graphs that uses space and query time, and is a -approximation for some constant ?
Using our new tools, we answer Question 2 in the affirmative: we obtain a -approximate ADO with query time, space, and preprocessing time.
Corollary 2 (ADO-unweighted). There is an -time algorithm that constructs a -approximate ADO for unweighted undirected graphs, with space and query time.
Table 1 compares our ADOs with the previous ADOs with nonconstant query time.
The -PSP, -PSP, and -PSP problems. The -pairs shortest paths problem (-PSP) generalizes APSP by asking only for the distances between a prescribed set of pairs, instead of all pairs. Specifically, given a set of pairs, the goal is to compute an estimate for every . The -PSP problem has been studied since the 1990s by Cohen [Coh98] and by Aingworth, Chekuri, Indyk, and Motwani [ACIM99], and has received renewed attention in recent years [DJWW22, CHL25, KRV26a]. This line of research has focused primarily on the case , which we denote by -PSP. We write -PSP for the case .
We first discuss -PSP algorithms running in time, and then those with an additional term in the running time.
Running time . For unweighted graphs, Dalirrooyfard, Jin, Vassilevska Williams, and Wein [DJWW22] obtained a -approximation for -PSP in time. Chechik, Hoch, and Lifshitz [CHL25] later obtained a purely multiplicative -approximation in the same running time, for , in both unweighted and weighted graphs. The main open problem in this regime is whether the barrier can be broken:
Question 3. Is there a -approximation algorithm for -PSP in unweighted graphs that runs in time, for some constant ? Is there such an algorithm for weighted graphs?
We answer both parts of Question 3 in the affirmative. We present a -approximation algorithm that runs in time on weighted graphs, and hence also on unweighted graphs. Moreover, it handles pairs instead of .
| Graphs | Reference | #Pairs | Running time | Approximation |
|---|---|---|---|---|
| Weighted | [TZ05] | t | ||
| [CHL25] | n | |||
| [KRV26a] | n | |||
| Theorem 3 | m | |||
| Unweighted | [DJWW22] | n | ||
| [CHL25] | n | |||
| [CHL25] | n | |||
| [KRV26a] | n | |||
| Theorem 4 | n | |||
| Theorem 3 | m |
Table 2: n-PSP and m-PSP algorithms.
Theorem 3 (m-PSP-weighted). There is an -time -approximation algorithm for m-PSP in weighted undirected graphs.
Running time . With an additional term in the running time, better leading coefficients were known. In unweighted graphs, Chechik, Hoch, and Lifshitz [CHL25] obtained a -approximation, and Kadria, Roditty, and Vassilevska Williams [KRV26a] improved it to a purely multiplicative -approximation, for . Both results analyze the same algorithm, which connects and through the middle vertex of their shortest path (see Section 3). In weighted graphs, Kadria, Roditty, and Vassilevska Williams [KRV26a] obtained a -approximation. Theorem 3 already improves upon this result. It has a smaller leading coefficient, it runs in time, and it handles pairs instead of . The main open problem in this regime is whether this running time suffices for stretch :
Question 4. Is there a multiplicative -approximation algorithm for -PSP that runs in time?
In unweighted graphs, we answer Question 4 in the affirmative. Using our new analytical tools, we show that the algorithm of [KRV26a] is a -approximation algorithm for -PSP. This improves the leading coefficient from to exactly with the same running time. Moreover, the leading coefficient is tight for this algorithm (see Section 4).
Theorem 4 (n-PSP-unweighted). There is an -time -approximation algorithm for n-PSP in unweighted undirected graphs.
When , the running time of Theorem 4 is . Hence, for such graphs, Theorem 4 also answers, up to the same additive , the question of Dalirrooyfard, Jin, Vassilevska Williams, and Wein [DJWW22], who asked whether a -approximation for -PSP is possible in time.
Table 2 summarizes our -PSP and -PSP results and compares them with previous algorithms.
-PSP: ST-shortest paths and MSSP. Two extensively studied problems that are closely related to -PSP (see, e.g., [Kle05, CC07, CCE13, EK13, DHZ00, Elk05, DJWW22]) are multiple-source shortest paths (MSSP) and ST-shortest paths (-SP). Given a set , MSSP asks to estimate for every . Given two sets , ST-SP asks to estimate for every . All of these problems are special cases of a single source-sensitive problem, which we call -PSP.
Definition 5 ((t, s)-PSP). The input is a set of prescribed pairs such that there exists a set of sources that hits every pair, that is, for every . The goal is to compute an estimate
| Graphs | Problem | Reference | Running time | Approximation |
|---|---|---|---|---|
| Weighted | (t, s)-PSP | [RTZ05] | ||
| Theorem 6 | ||||
| MSSP | [RTZ05] | |||
| Theorem 10 | ||||
| Unweighted | (t, s)-PSP | [RTZ05] | ||
| Theorem 7 | ||||
| MSSP | [RTZ05] | |||
| Theorem 11 |
Table 3: -PSP and MSSP algorithms. Here, is the number of sources (for MSSP, ).
for every .³
For example, -PSP is -PSP, -PSP is -PSP, and -PSP is -PSP. Similarly, -SP is -PSP, and MSSP is -PSP.
Using our new tools and ideas from the parameterized distance oracles of [KR26a, RTZ05], we obtain the following result for -PSP in weighted graphs:
Theorem 6 ((t,s)-PSP-weighted). There is an -time -approximation algorithm for -PSP in weighted undirected graphs.
Thus, the factor in the running time of Theorem 3 is replaced by : the cost is governed by the number of sources , rather than by the number of vertices .⁴
For unweighted graphs, we obtain:
Theorem 7 ((t,s)-PSP-unweighted). There is an -time -approximation algorithm for -PSP in unweighted undirected graphs.
As immediate corollaries, we obtain algorithms for -SP and MSSP. Let . For -SP, we substitute and :
Corollary 8 (-SP-weighted). There is an -time -approximation algorithm for -SP in weighted undirected graphs.
Corollary 9 (-SP-unweighted). There is an -time -approximation algorithm for -SP in unweighted undirected graphs.
For MSSP, we substitute and :
Corollary 10 (MSSP-weighted). There is an -time -approximation algorithm for MSSP in weighted undirected graphs.
Corollary 11 (MSSP-unweighted). There is an -time -approximation algorithm for MSSP in unweighted undirected graphs.
Table 3 compares these results with the source-restricted ADO of Roditty, Thorup, and Zwick [RTZ05].
Finally, by taking in Theorems 6 and 7, we obtain the following algorithms for -PSP. When , they improve upon Theorems 3 and 4 by replacing the factor in the running time with . In the unweighted case, this comes with a slightly larger stretch, instead of .
³The set does not need to be given. Scanning the pairs one by one and adding both endpoints of every pair that is not yet hit gives, in time, a hitting set of size at most .
⁴The constant term in the stretch grows from 7 in Theorem 3 to 11, since with sources the hierarchy no longer starts at , which adds at most to the estimate. See Section 8.
Corollary 12 (t-PSP-weighted). There is an -time -approximation algorithm for t-PSP in weighted undirected graphs.
Corollary 13 (t-PSP-unweighted). There is an -time -approximation algorithm for t-PSP in unweighted undirected graphs.
Hopsets. A b-hops -approximation hopset is a set of weighted edges whose addition to preserves distances and gives every pair a path in with at most edges and length at most . Hopsets have been studied extensively, both in upper bounds [Coh00, MPVX15, HKN18, EN19, HP19, BP20, EM21, EN22, KP22b, NS22, BW23, ABD25] and in lower bounds [ABP18, KP22a, NS22, BH23, HXX25].
Huang and Pettie [HP19] observed that the Thorup-Zwick [TZ05] distance oracle yields a 2-hops -approximation hopset of size , and asked the following question:
Question 5. Are other tradeoffs between size and stretch possible for hopsets whose hopbound is a fixed constant, such as 3 or 4, independent of ?
We answer this question in the affirmative and present several new hopsets with constant hopbounds that break the barrier. For unweighted graphs, we obtain a -approximation with 4 hops:
Corollary 14 (Hopset-unweighted). There is a 4-hops -approximation hopset of size for unweighted graphs.
For weighted graphs, we obtain three hopsets with 3, 4, and 5 hops. Each additional hop improves the tradeoff: the fourth hop reduces stretch, and the fifth reduces size. First, with 3 hops and edges, we obtain stretch :
Corollary 15 (Hopset-weighted-3-hops). There is a 3-hops -stretch hopset of size for weighted graphs.
With one additional hop, we reduce the stretch to at the same size.
Corollary 16 (Hopset-weighted-4-hops). There is a 4-hops -stretch hopset of size for weighted graphs.
A fifth hop preserves stretch while reducing the hopset size to .
Corollary 17 (Hopset-weighted). There is a 5-hops -stretch hopset of size for weighted graphs.
The Thorup-Zwick bunches and pivots used by Theorems 4 and 14 are also nearly optimal in the pivot-based model of Kadria and Roditty [KR26b]. In a -pivot -hop ADO, every vertex has at most pivots, including itself, and every estimate is the length of a walk of stored distances with at most hops, where, unlike in a hopset, pivot jumps between a vertex and one of its pivots are not counted as hops. Every estimate in our analysis of Theorem 4 is the length of a walk , where , and are Thorup-Zwick pivots of , and , respectively, and the only hops are the bunch distances from to and from to . Since this holds for every pair , the Thorup-Zwick bunch and pivot distances form a -pivot 2-hop -approximation ADO with space. Under the Erdős girth conjecture, there are sparse unweighted graphs on which every -pivot 2-hop ADO with space has stretch at least , even with an additive error independent of [KR26b]. Thus, within this model, the leading coefficient is optimal up to an additive 1.
Short paths. In addition, we obtain an improved algorithm for -PSP when the shortest paths of the queried pairs have at most two edges. This result also answers a question of Kadria and Roditty [KR25b], who asked whether stretch exactly is achievable for vertex pairs at distance 2 in unweighted graphs:
Theorem 18 (-PSP-short paths). There is an -time -approximation algorithm for -PSP in weighted undirected graphs, for queried pairs whose shortest path has at most 2 edges.
Related work: Conditional lower bounds. Abboud, Bringmann, Khoury, and Zamir [ABKZ22] initiated the study of conditional lower bounds for approximate distance oracles with nonconstant query time. Building on their work, Abboud, Bringmann, and Fischer [ABF23] and, independently, Jin and Xu [JX23] proved stronger lower bounds under the 3SUM hypothesis: for a fixed , every ADO with preprocessing time and query time must have stretch at least , even in unweighted graphs. Jin and Xu [JX23] also proved lower bounds for the offline setting, in which all pairs are given in advance. In particular, their result [JX23, Theorem 1.9] implies that, for every integer and constant , there is no -approximation algorithm for -PSP that runs in time, even in unweighted graphs, unless the 3SUM hypothesis fails. Hence, the leading coefficient of Theorem 3 is within a factor of of the best possible.
For pairs at distance 2, Jin and Xu [JX23] proved, under the 3SUM hypothesis, that for every constant integer and every , there is no -time algorithm that -approximates the distances of given pairs in an unweighted undirected graph with , even when every queried pair is at distance at most 2. On such graphs, , so their lower bound rules out stretch in time. Applying it with in place of (for even ) shows that no algorithm with stretch runs in time. Since a pair at distance 2 in an unweighted graph has a shortest path with 2 edges, Theorem 18 applies, and it achieves stretch in time, which is within a factor of 2 of this lower bound. A similar factor of 2 in the stretch appears for ADOs. Jin and Xu [JX23] also rule out a -stretch ADO with preprocessing time and query time on graphs with edges. Applying it with in place of shows that no such ADO with stretch has preprocessing time, whereas the Thorup-Zwick ADO with stretch is constructed in time on such graphs. It is therefore plausible that in both cases the lower bound, rather than the algorithm, can be improved, in which case Theorem 18 would be tight.
Organization. In Section 2 we fix our notation and review the Thorup-Zwick hierarchy, and in Section 3 we give a technical overview of our three growth lemmas and of how they replace the middle-vertex analysis. In Section 4 we prove the Mixed-Level Growth Lemma and use it to obtain the unweighted -approximation of Theorem 4, and in Section 5 we present the -approximation algorithm of Theorem 3, together with the Two-Level Growth Lemma and the Long-Short Growth Lemma. In Section 6 we prove Theorem 18, which shows that stretch is achievable for pairs whose shortest path has at most two edges. In Section 7 we derive our ADOs, Theorems 1 and 2, and our hopsets, and in Section 8 we generalize our algorithms to -PSP, obtaining Theorems 6 and 7 and their corollaries for ST-SP, MSSP, and t-PSP. Finally, the numerical optimization lemmas used by our stretch analyses, Lemmas 6 and 11, are proved in Section A.
The Thorup–Zwick hierarchy. In our algorithms, as well as in many distance-related algorithms (n-PSP, distance oracles, all-pairs shortest paths, multiple-source shortest paths, spanners, etc.), one uses a vertex hierarchy , where contains every vertex from with probability for every . For every vertex , let , , and
and let . We call the -th pivot of , and the bunch of . Note that for every . Since , we have , and hence . We write for the set of levels. For a vertex , we write for and for , and call them the one-level and two-level growth of at level .
Thorup and Zwick [TZ05] also presented an efficient algorithm for computing for every , as described in the following lemma.
Lemma 1 ([TZ05]). There is an -time algorithm that computes, for every , the set and the distances from u to every .
Thorup and Zwick [TZ05] showed that this hierarchy can be used as an approximate distance oracle. The following lemma is the main ingredient in their analysis. We present the proof as a warm-up for later sections.
Lemma 2 ([TZ05]). Let and . If , then , and
Proof. By the triangle inequality, . Since and , it follows that .
In addition,
as required.
Moreover, a one-level gap of more than twice the distance gives both inclusions at once.
Lemma 3. Let and . If , then and .
Proof. Since , we have , and Lemma 2 gives . Since , we have , and Lemma 2 gives .
Thorup and Zwick [TZ05] proved the following bound on the size of the bunches.
Lemma 4 (Lemma 3.5 in [TZ05]). with high probability.
3 Technical overview
In this section, we give an overview of the new machinery developed in this paper, specifically the Mixed-Level Growth, Two-Level Growth, and Long-Short Growth lemmas. For simplicity, we present their application to the n-PSP and m-PSP problems, and then briefly discuss the implications for other problems.
We begin by explaining how previous analyses improve upon the classical stretch, and what limits their improvement. The baseline is to construct the Thorup-Zwick oracle and query it: the query searches for a pivot or through which to connect and . This gives stretch with query time and preprocessing time, and hence an -time algorithm for -PSP with the same stretch. For -PSP and -PSP, we can inspect more than the pivot-to-bunch candidates of a standard oracle query. These additional candidates allow us to improve on the stretch.
First, we consider unweighted graphs. All previous algorithms [CHL25, KRV26a] operate as follows. During preprocessing, they construct a table , where is the minimum of over all

Figure 1: The estimate of Algorithm 1, where , , and .
vertices with . A query then examines every and returns as the minimum of . In particular, if for some vertex on there are and , then these two bunch elements provide a connection through . We call a connecting vertex for (see Figure 1). Constructing takes additional time, and querying each pair takes time, yielding an -time algorithm.
Previous papers [CHL25, KRV26a] showed that this algorithm gives a -approximation, using the middle vertex of , i.e., the vertex at equal distance from and , as the connecting vertex. We re-derive the bound in a form that exposes its bottleneck, and then show how our analysis removes it.
Recall that is the two-level growth at . Consider a pair with , where is even, and let be the middle vertex of , i.e., .
The middle-vertex analysis checks when is a “good” connecting vertex for the pair . Assume that for some level . Then
and therefore or . By Lemma 2, either or (see Figure 2). Until such a growth occurs, the pivot distance grows by at most every two levels. The same argument applies independently if . If such a growth occurs at both endpoints, possibly at different levels, then serves as a connecting vertex for . Combining these middle-vertex connections with the classical Thorup-Zwick search gives the -approximation. Roughly, if the pivot distances grow by about per level up to some level , a connection through at level gives an estimate of about , while continuing the Thorup-Zwick search from level gives about . Balancing the two at gives . If we consider only the middle vertex as a possible connecting vertex, then this analysis is tight.

Figure 2: Claim 5.3. Since , at least one of the two terms is larger than , and hence one of the paths (a) and (b) exists.
The middle-vertex analysis has an inherent limitation: since is fixed in advance, it requires sufficient growth at each endpoint separately. To see this, note that the argument above shows that a two-level growth at lets connect to every vertex of with . We say that reaches .
Similarly, reaches every vertex with , and a vertex reached by both endpoints is a connecting vertex. Since the middle vertex satisfies , the previous analyses must wait for a level with and a level with . Extra growth at one endpoint cannot compensate for missing growth at the other.
For example, suppose that and . Then reaches every vertex at distance at most from it, which is almost all of , while reaches only the vertices at distance at most from it, which excludes the middle vertex. Hence, the middle vertex is not a connecting vertex for the levels and . Nevertheless, the portion of reached from and the portion of reached from overlap, and every vertex in the overlap is a connecting vertex (see Figure 3).

Figure 3: The Mixed-Level Growth Lemma (Lemma 5). The ranges and overlap (shaded). The middle vertex is outside the overlap, while every vertex in the overlap satisfies the conditions of Claim 5.2.
This is the main new idea behind the Mixed-Level Growth Lemma. We do not fix the connecting vertex in advance. Instead, we consider all vertices of and choose the connecting vertex according to the growth at both endpoints. Such a vertex exists whenever the two reached portions together cover , which happens if . Thus, only the total growth at the two endpoints matters, and not how it is split between them. This seemingly small change affects only the analysis, not the algorithm. Nevertheless, it suffices to obtain the -approximation of Theorem 4. We formalize this in the Mixed-Level Growth Lemma below.
Tool I: The Mixed-Level Growth Lemma. In an unweighted graph, if for some ,
then some vertex is a connecting vertex for , and the estimate returned by the query satisfies
The growth at each endpoint determines how far the connecting vertex can be from it. Instead of fixing at the middle vertex, we let be the last vertex of with , and show that if Condition (1) is met, then and . Thus, we can use the same proof idea as for the middle vertex to show that this is a good connecting vertex for .
The lemma, together with the last-level Thorup-Zwick estimate , reduces the remaining analysis to a numerical problem. For any pair of levels at which (2) would give a sufficiently short estimate, the absence of such an estimate forces . Combining these growth constraints with the last-level estimate yields the bound , while preserving the previous running time.

(a)

(b)
Figure 4: The two walk shapes used in the analysis of Algorithm 2, where . In (a), and . In (b), and . The dotted edge is the entry of set for .
Removing the extra running-time term. The extra running time arises in two places. First, the preprocessing stores for all pairs , for every vertex , which takes time. Second, the query examines all pairs in , which takes time per query, and time overall. We change both parts.
The query. Instead of all of , the query examines only the mixed pairs
which takes time per pair.
The preprocessing. Pairs of bunch elements of a common vertex are no longer stored. Instead, we use the preprocessing technique of [KRV26a], which also handles the difficulty that weighted graphs introduce: the ideal position of the connecting vertex may lie inside a heavy edge, and moving it to either endpoint may exhaust the available growth. For every oriented edge , every level , and every , we update and with the length of the walk , which crosses the edge directly. This takes time.
Every estimate that the query returns is the length of a u-v walk, and our analysis uses only walks of the forms
where is an edge of (see Figure 4). The total running time is for pairs.
The main challenge is to prove that the mixed connections alone suffice for a small stretch. For this, we develop the following two tools.
Tool II: The Two-Level Growth Lemma. If for some ,
then
The same statement holds with u and v exchanged.
The lemma splits a gap across the two endpoints rather than at a single endpoint. For every ,
so by Lemma 2, or . Moving along , we find an edge with
and . Unlike in the Mixed-Level Growth Lemma, the pivot used on each side is fixed in advance, and the two always form a mixed pair. This gives the estimate of type (b) in Figure 4.
The lemma helps us control the growth of the lower levels. Whenever (5) would give a sufficiently short estimate, the absence of such an estimate forces Condition (4) to fail in both orientations: and . Adding these inequalities gives
which is the constraint of the Mixed-Level Growth Lemma for , now obtained from mixed pairs alone and in weighted graphs. Thus, and together grow by at most every two levels, that is, by about per level per endpoint on average. For pivot distances around , each endpoint contributes about to (5), since the lemma pairs level at with level at . The total is about , which is below the target of about only for . To handle the higher levels, we need a lemma that pairs a high level at one endpoint with a low level at the other, so that only one endpoint contributes a large term. The Long-Short Growth Lemma does exactly this. It combines a two-level growth at level of one endpoint with a one-level growth at an arbitrary level of the other, and gives an estimate of about .
Tool III: The Long-Short Growth Lemma. Recall that is the one-level growth at , and that is the two-level growth at . The Long-Short Growth Lemma states that if
then
The same statement holds with u and v exchanged.
The intuition is to first handle a long part of , and then use the short remaining part to complete a mixed estimate. Condition (6) says that the range of the long gap, , and the range of the short gap, , together cover , so they meet at some point (see Figure 5). In an unweighted graph, we may take to be a vertex and set , at the cost of increasing the threshold in Condition (6) by an additive constant, as in Tool I. In a weighted graph, may lie inside a heavy edge . In this case, we let the long part end at and the short part start at , so that and , and use the entry of recorded for to cross the edge at no extra cost.

Figure 5: Claim 10.1. The two ranges overlap at a point of the edge , which may be heavy. The point is not a vertex but a point inside that is used only in the analysis.
On the long part, as before, guarantees either a pivot of in or a pivot of in . We allow either outcome, and then look on the short part for the pivot that completes it: a pivot of in in the first case, and a pivot of in in the second.
To be ready for both outcomes, the short part uses the one-level condition , which guarantees both pivots at once (see Lemma 3). This is more expensive, as the growth must now occur within a single level rather than over two levels, but since the part is short, the extra cost is small. The two outcomes give exactly the two walk shapes of Figure 4.
Obtaining the bound. The two lemmas constrain different parts of the growth. The Two-Level Growth Lemma limits growth at lower levels, where the sum of the pivot distances is still small. The Long-Short Growth Lemma then relates later two-level increments to earlier one-level increments. Each constraint applies whenever the corresponding estimate would be sufficiently short. Combining these constraints with the last-level Thorup-Zwick estimate reduces the analysis to a numerical optimization problem, whose solution guarantees an estimate of at most , giving the claimed stretch in total time. In Section 5.5, we give the intuition behind this solution and show that the constant is tight for the estimates of our algorithm. See also Figure 6 for a hard instance.
Adapting to other problems. We presented our tools through -PSP and -PSP, where their application is simplest to explain. The lemmas themselves describe general properties of the Thorup-Zwick hierarchy and are not specific to these problems.
Our modification for distance oracles in weighted graphs is simple: the preprocessing is independent of the queried pairs, and therefore we compute and store in the preprocessing phase and compute the estimate upon receiving a query. For unweighted graphs, we show that one can reduce the space to by not storing the edge-related distances, at the cost of an additional additive error.
To cover ST-SP and MSSP, we study the more general -PSP problem, in which each of the requested pairs has an endpoint in a set of sources. Following the parameterized distance-oracle construction of [KR26a, RTZ05], we set and sample the remaining levels as usual. Because our growth lemmas depend only on pivot-distance increments at the queried endpoints and, in weighted graphs, on differences between the pivot distances of the two endpoints, the analysis carries over with at most additional error in unweighted graphs and at most in weighted graphs. This yields running times for weighted graphs and for unweighted graphs.
4 -approximation in time
In this section, we provide a -approximation algorithm for -PSP that runs in time. The algorithm is the same as that of [KRV26a], which is a simplification of [CHL25]. The main contribution of this section is a more precise analysis of that algorithm, which establishes the -approximation guarantee.
Reminder of Theorem 4. There is an -time -approximation algorithm for -PSP in unweighted undirected graphs.
Throughout this section, let be the set of queried vertex pairs.
4.1 The previous (and current) algorithm
The algorithm works as follows. First, the algorithm initializes two empty hash tables and , and for every computes using Lemma 1.5. Then, for every and every , the algorithm sets to . Next, for every vertex pair and every and , the algorithm sets to . The algorithm returns for every . Pseudocode for the algorithm is presented in Algorithm 1, and the estimate that it evaluates is illustrated in Figure 1.
returns on unset pairs, and for every .
Algorithm 1: -approximation for -PSP
1
2 Compute for every [Lemma 1]
3 for do
4
5
6 for do
7
8
9 return
4.2 Our analysis
For the rest of this section, fix a pair , and let . Recall the two-level growth from Section 2. Our analysis avoids fixing the connecting vertex on in advance. Given levels and , we choose a vertex according to the relative values of and . The following lemma shows that it is enough for their sum to be large: the single condition guarantees a short estimate. Thus, a larger increase at one endpoint can compensate for a smaller increase at the other endpoint.
Lemma 5 (Mixed-Level Growth Lemma). Let , and let . If
then .
Proof. We divide the proof into three claims. First, we show that a single large two-level growth already gives the desired approximation.
Claim 5.1. If for some , , then . This holds symmetrically for v.
Proof. Suppose first that . By Lemma 2, . Moreover, the triangle inequality gives , so as well. Therefore,
Otherwise, . Since , we have
By Lemma 2, . Also, , so . Hence,
By the previous claim, we may assume that . Together with (1), this implies that .
Claim 5.2. There exists a vertex such that
Proof. For every vertex , we define
Our goal is to find a vertex such that and . See Figure 3 for an illustration.
Let be the last vertex of , starting from , such that . Such a vertex exists since , so . Moreover, since , we have , and therefore comes before on the path.
Since the graph is unweighted, decreases by 2 at each edge traversed from to . Since is the last vertex such that , we have . By (1),
Thus, , and satisfies both required inequalities.
We show that can act as a connecting vertex. For this, we choose between and , using the former whenever (see Figure 2).
Claim 5.3. There exists such that and
Proof. Suppose first that , and choose . By Lemma 2, . Moreover,
so as well. The triangle inequality gives
Otherwise, , and we choose . By Claim 5.2,
Thus, Lemma 2 gives . Also, , so . Finally,
as required.
Choose as in Claim 5.3, and symmetrically choose such that
Since , the algorithm ensures that . Moreover, and , so the query considers this pair and gives
as required.
Next, we use Lemma 5 to obtain a good approximation ratio for the algorithm. We have the following two bounds.
-
.
-
If , then .
At this point, all graph-theoretic aspects of the analysis are captured by the two bounds above, and it remains only to solve a purely numerical optimization problem. We first assume that is odd, and set , , and .
Lemma 6. Let and be integers, and let be a real number. Let be nonnegative integers for every . Then
We defer the proof of the lemma to Section A.
In our algorithm, is at most twice the optimization target of Lemma 6 with c = 0 plus D. Therefore,
This proves the theorem when k is odd.
Now assume that k is even. Then the k-1 levels cannot be split into two-level increments, and one level is left over. We pair the first level of one endpoint with the top level of the other endpoint. That is, we connect a vertex at distance about from u directly to v through the top level of the hierarchy.
Lemma 7. If , then . The same holds with u and v exchanged.
Proof. Let be the vertex of with . Then . Indeed, either , or and Lemma 2 gives . Moreover, .
We connect to through the top level, as in Claim 5.3. Suppose first that , and let . By Lemma 2, . Moreover, , so , and . Otherwise, , and we let . Since , we have , and
In both cases, , so the algorithm ensures that . Since and , the query gives
as required.
Let . We may assume that . Indeed, if, say, , then by Lemma 2, and the query returns . We distinguish two cases.
Case 1: . Set and for . Then and . By Lemma 7 with and exchanged, and ,
and symmetrically . By Lemma 5 with levels and , if , then
Thus, is at most twice the optimization target of Lemma 6 with plus , and
Case 2: . The case is symmetric. Here, we use the odd levels of and the even levels of . Set and for , and . Then and . The first bound above gives
By Lemma 7,
By Lemma 5 with levels and , if , then
Thus, by Lemma 6,
This proves the theorem when k is even.
Next, for completeness, we prove that the running time of the algorithm is .
Lemma 8 (Lemma 7 of [KRV26a]). The algorithm takes time.
Proof. Computing for every takes time. Constructing requires time. Estimating the distances takes time. Therefore, the running time is , as required.
Lower bound for the k-stretch algorithm. The factor k is tight for this algorithm: consider a pair at distance for which the relevant pivot distances increase by at each level. The hierarchy can be arranged so that the strict bunch inequalities are never satisfied along before the last level, and hence no shorter route is available through a connecting vertex at any level. At level , the first available route can have length .
5 -stretch in time
In this section, we provide a -multiplicative approximation algorithm for -PSP that runs in time, for both weighted and unweighted graphs. We remove the time-consuming parts of Algorithm 1 and instead use (only) a preprocessing technique from [KRV26a], originally introduced to obtain a -approximation algorithm for -PSP on weighted graphs.
Reminder of Theorem 3. There is an -time -approximation algorithm for -PSP in weighted undirected graphs.
Throughout this section, let be the set of queried vertex pairs.
We first explain which parts of Algorithm 1 cause its high running time and why its stretch analysis does not extend to weighted graphs, and describe how [KRV26a] overcame the latter issue and obtained a stretch better than .
5.1 The problems (and some of the solutions) of Algorithm 1
When , the running time of Algorithm 1 is dominated by the term. This term arises in two places. First, during preprocessing, we store in the distances between every pair of vertices in , for every . These distances are used when the estimate is obtained through :
Second, during the query, we examine every pair in . This is needed when we find and , giving
This algorithm also fails to achieve the same stretch guarantee in weighted graphs. In Lemma 5, the additive 3 accounts for rounding the ideal split point on the path to a nearby vertex. In a weighted graph, however, a single edge of may contain almost the entire distance , so this rounding can incur an additive loss at each relevant step. Consequently, the stretch deteriorates back to .
Kadria et al. [KRV26a] improved the stretch by augmenting the preprocessing as follows: for every oriented edge and every , they also stored for every . Over all edges, this requires only time.
If is a heavy edge on , this preprocessing stores whenever , whenever , and for every . In all three cases, the connection can cross the heavy edge directly through the stored entry in , instead of forcing the analysis to round the split point to either or and pay for the edge weight. However, the preprocessing does not provide . This remaining case prevents the weighted analysis of [KRV26a] from matching the stretch obtained for unweighted graphs, resulting instead in a stretch of approximately 1.622k.
5.2 Our algorithm
We show that a stretch of can be guaranteed, and our analysis uses only estimates of the forms
where is an edge of and . The query may find other walks as well, but every estimate is the length of some walk, so . Restricting the analysis to these two forms helps us in three ways:
-
It eliminates the preprocessing over all pairs in , removing the term.
-
It replaces the search over by considering and , which takes time per pair. Consequently, the algorithm solves -PSP in time.
-
It allows us to incorporate the weighted-graph preprocessing technique of [KRV26a] without any additional loss in the stretch.
The algorithm works as follows. It first initializes two empty hash tables and , and computes for every using Lemma 1.⁶ Then, for every oriented edge , every , and every , it sets and to . Next, for every pair , the algorithm considers two types of estimates. For every and , it sets to . Symmetrically, for every and , it sets to . Finally, the algorithm returns for every . Pseudocode is presented in Algorithm 2. See Figure 4 for an illustration of a possible estimate.
Algorithm 2: -approximation for -PSP
1 2 Compute for every using Lemma 1; 3 4 5 6 7 8 9
To obtain the improved approximation guarantee, we develop two new analytical tools for the Thorup-Zwick hierarchy, formalized in the Two-Level Growth Lemma and the Long-Short Growth Lemma, that translate large increases of the pivot distances and into short query paths. We describe these lemmas next. Together, they reduce the approximation analysis to a numerical optimization problem whose solution yields the improved stretch.
For the rest of this section, fix a pair , and let and . Recall the one-level growth and the two-level growth from Section 2.
5.3 The Two-Level Growth Lemma
Lemma 9 (Two-Level Growth Lemma). If for some ,
then
This lemma holds symmetrically when switching between and .
⁶As in Algorithm 1, returns on unset pairs, and for every .
Intuitively, we use the intermediate level to connect level at to level at . Notice that for every ,
Since , either or holds. Moving along the path, we find an edge such that
SO
Processing this edge stores a connection between and , which the query uses to connect u to v.
Proof. We first handle the cases in which a pivot of u or v suffices. If , then
By Lemma 2, , and the direct query gives
which is stronger than the required bound. If , then Lemma 2 gives , and again
We may therefore assume that
As in the proof of Lemma 5, we now find a connection along . Here, the connection uses an edge rather than a single vertex.
Claim 9.1. There exists an edge of , oriented from to , such that
Proof. For every vertex , define
Our goal is to find an edge with and . For every ,
Moreover, our assumptions give and .
Let be the first vertex of , starting from , such that , and let be its predecessor. Then , so
Thus, satisfies both required inequalities.
By Claim 9.1 and Lemma 2.
Therefore, when processing the edge , the algorithm ensures that
where we used that the weight of equals , since it lies on a shortest path.
The query considers this pair of pivots and gives
Finally, Claim 9.1 and the triangle inequality give, respectively,
Adding these inequalities yields
Substituting into the bound above, we obtain
as required.
5.4 The Long-Short Growth Lemma
Lemma 10 (Long-Short Growth Lemma). If for some and ,
then
This lemma holds symmetrically when switching between u and v.
Intuitively, the argument works as follows. We choose close to v, so that the subpath from u to x contains almost all of . We first handle this long subpath. If
then one of two possibilities must hold: either a pivot of belongs to , or a pivot of belongs to . At this stage, we deliberately keep both possibilities open. We only care that the long part of the path is covered, not whether it is covered through a pivot of or through a pivot of .
Once this choice is made, the short subpath from to must complete the corresponding connection. If the long part uses a pivot of , we need a pivot of that belongs to . If the long part uses a pivot of , we instead need a pivot of that belongs to . The one-level gap
guarantees both possibilities. Thus, the short part can adapt to whichever choice was made for the long part. This is similar to a Thorup-Zwick routing argument between x and v: the large gap guarantees that the appropriate previous-level pivot of one endpoint belongs to the bunch of the other endpoint.
Since , it is enough that
Moreover, by adding for every edge , every level , and every , we can split the path across the edge , and check whether
This is particularly useful in weighted graphs, where the ideal split point may lie inside a heavy edge. Without this preprocessing, we would have to move the split point to either x or y, forcing one side of the analysis to include the full weight of the edge. Instead, the first part only needs to reach x, while the second part starts from y, and the stored connection crosses the edge directly. Thus, we do not need to pay for the weight of in either of the two gaps.
We now prove the Long-Short Growth Lemma. We assume that .^7 We split the rest of the proof into two claims.
Claim 10.1 (Long-Short Growth Lemma Part 1). If for some and ,
then there exists an edge of P, oriented so that u,x,y,v appear in this order, such that
Proof. See Figure 5 for an illustration. We view each edge of as a continuous interval whose length equals its weight. Thus, every value in is the distance of some point on .
By the assumptions,
We can choose a point on the continuous path such that . Note that is not necessarily a vertex of : it may be an imaginary point in the interior of an edge, and it is used only in the analysis, not by the algorithm.
Let be the edge containing , oriented so that appear in this order. Since appears before ,
Similarly, since appears after , we have , and therefore . Thus, satisfies both required inequalities.
Claim 10.2 (Long-Short Growth Lemma Part 2). Let be an edge of , oriented so that appear in this order. Suppose that there are and such that
Then
Proof. We first use the two-level gap at u. We have
Since this quantity is greater than , at least one of the following inequalities holds:
By Lemma 2, in the first case , and in the second case .
If , then Lemma 2 gives or . If , then Lemma 3 gives . In each case, the direct query already gives the required bound.
We next use the one-level gap at . Since , Lemma 3 gives both and .
Thus, if , the preprocessing for the edge lets the algorithm consider the walk
In this case,
where in the last inequality we used the fact that . Moreover,
Therefore,
The case where the query uses and follows similarly and yields a slightly stronger bound.
5.5 The optimization
Next, we use both the Two-Level Growth Lemma and the Long-Short Growth Lemma to obtain a good approximation ratio for the algorithm. We have the following three bounds.
-
.
-
By Lemma 9, if , then . This holds symmetrically when switching between u and v.
-
By Lemma 10, if , then . This holds symmetrically when switching between u and v.
At this point, all graph-theoretic aspects of the analysis are captured by the bounds above. It remains to show that at least one of these bounds is sufficiently small.
We apply the following lemma with and , so that and .
Lemma 11. Let with , and for every let and . Then
We may assume , since otherwise a direct level-zero query already returns the exact distance D.

Figure 6: The pivot distances that are tight for Lemma 11, with . Both and are .
We defer the proof of Lemma 11 to Section A.2. Let Q denote the value of the minimum in the lemma. By the definitions of , and , every feasible expression in this minimum gives, through the corresponding bound above, an estimate of at most 2D times that expression plus 3D. Therefore,
Although the proof is rather long and technical, we illustrate the main idea under the simplifying assumption that for every i (see Figure 6). In this case, and for every i, and the optimization problem reduces to showing that
Let denote the value of this optimization problem, and let be the largest index such that . By the maximality of , we have , so . Moreover, for every ,
Therefore, the two-level term implies . Summing over disjoint pairs of consecutive increments gives .
To illustrate the main idea, we ignore additive constants and think of the transition as occurring around and . Thus, the average value of the increments is approximately . Suppose, for simplicity, that all these increments are exactly .
Now consider a later level . As long as , the long-short term in the optimization problem implies . Taking any , for which , gives . Hence, the average increase after level is at most . The first levels contribute approximately to , while the remaining levels contribute at most approximately . Since , we obtain
Moreover, we have . Substituting this relation gives , which rearranges to .
Lastly, we prove that the running time of the algorithm is and complete the proof of Theorem 3.
Lemma 12. Algorithm 2 runs in time.
Proof. Computing for every takes time. Constructing requires, for every edge and every , computing the values for every . For every edge, this takes time, so for all edges this takes time. Estimating the distances takes
Therefore, the running time is , as required.
Lower bound for the 6/5 constant. Let and let be an integer. In our lower-bound instance, and are symmetric, and their pivot distances follow a two-phase profile: grows by per level up to level , and by per level afterwards (see Figure 6). This is the fastest profile that the Two-Level Growth Lemma and the Long-Short Growth Lemma permit, the first phase being bounded by the former and the second by the latter.
In this hierarchy, every walk considered by Algorithm 2 incurs at least one of the following two costs.
- Walks through a pivot of the last level , whose distance to is therefore traversed twice:
- Walks through two separate pivots of level about . The bunch and pivot conditions force both pivots to be at levels at least . Each is about from the path, and each detour is traversed twice:
Thus, both costs give stretch at least .
6 Achieving improved stretch for short paths
In this section, we show that the algorithm of Section 5 achieves stretch k on pairs whose shortest path is short, a case left open by the lower-bound discussions in Sections 4 and 5. We consider weighted graphs and pairs whose shortest path has at most two edges.
Reminder of Theorem 18. There is an -time k-approximation algorithm for m-PSP in weighted undirected graphs, for queried pairs whose shortest path has at most 2 edges.
Proof. Let be the set of queried vertex pairs, where has at most two edges for every . We run Algorithm 2 with parameter and choose for every . We evaluate each input pair in both endpoint orders and take the smaller estimate. This changes the running time by only a constant factor, so the running-time bound follows immediately from Lemma 12. It remains to prove the stretch guarantee.
Fix and assume that has exactly two edges. Write . By symmetry between and , assume that . In particular, .
Let be the smallest index such that or . Such an index exists since . We show that in either case, the additive error is at most .
By the minimality of i, we have
If , then
and therefore . Moreover, if , then , and hence . Otherwise, the triangle inequality gives , and hence
so again . Therefore, the query for gives
In the remaining case, , and
and therefore . Since this case can occur only when , the triangle inequality also gives , and hence
Thus, , and the query for gives
Therefore, in either case,
Every estimate considered by the algorithm is the length of a walk, and hence , as required.
7 Distance oracles with nonconstant query time
In Section 5, we presented a -approximation algorithm for m-PSP that runs in time. The preprocessing of the algorithm is independent of the set of queried pairs. Therefore, the same construction can be viewed as a distance oracle, where we perform the preprocessing once and evaluate each query using the query procedure of Algorithm 2.
Reminder of Theorem 1. There is an -time algorithm that constructs a -stretch ADO for weighted undirected graphs, with space and query time.
This result is particularly interesting for sparse graphs. When , the space becomes , matching, up to polylogarithmic factors, the size of the classical Thorup-Zwick distance oracle [TZ05], while obtaining a substantially smaller stretch at the cost of a larger query time.
7.1 The unweighted case
Recall why the table was needed in Section 5. In both the Two-Level Growth Lemma and the Long-Short Growth Lemma, the analysis identifies an edge of . The preprocessing of Algorithm 2 allows the query to connect a pivot associated with to a vertex in , and therefore to cross the edge directly. This is essential in weighted graphs, since the edge may have arbitrarily large weight.
In an unweighted graph, every edge has length one. We can therefore choose a vertex of instead of splitting the path across an edge. This changes the inequalities used in the two lemmas only by additive constants. Once the split occurs at a vertex, the required query is of one of the following two forms:
These are exactly the pairs that we examine during the query.
In the preprocessing phase, after constructing the standard Thorup-Zwick hierarchy, pivots, and bunches, the algorithm updates and with the value for every vertex , every , and every , keeping the minimum value for each entry. This takes only time per vertex.
Given a query , the algorithm returns the minimum of
and
It remains to explain why the stretch analysis of Section 5 continues to hold. We do not repeat the proofs of the Two-Level Growth Lemma and the Long-Short Growth Lemma. Instead, we describe the only change required in each proof.
The Two-Level Growth Lemma. We use the following unweighted version of the lemma.
Lemma 13. Let and . If
then the query returns an estimate of at most
The proof follows the original one, with the additive constant 3 allowing us to choose a single vertex at which both required strict inequalities hold, as in the proof of the Mixed-Level Growth Lemma. We then have and , so the required entry is stored during preprocessing.
The Long-Short Growth Lemma. We use the following unweighted version of the lemma.
Lemma 14. Let , , and . If
then the query returns an estimate of at most
The proof follows the original one, with the additive constant 3 allowing us to choose a single vertex at which both required strict inequalities hold, as in the proof of the Mixed-Level Growth Lemma. The required entry of is therefore stored during preprocessing using the pivot and bunch associated with this same vertex .
We now apply the numerical analysis of Section 5 with in place of . Since all distances are integral, the conditions and imply the hypotheses of the two modified lemmas above. Their conclusions remain valid when is replaced by , so the same analysis gives
Thus, the oracle is a -approximation. We therefore obtain Theorem 2.
Reminder of Theorem 2. There is an -time algorithm that constructs -approximate ADO for unweighted undirected graphs, with space and query time.
7.2 Hopsets
Our hopsets consist of the edges used by the walks in our analyses. Each such edge gets the length of a walk in between and as its weight, so adding it to preserves distances. Since our analyses hold for every pair , it suffices to count the hops of the walks that they use.
Let contain, for every , the edge of weight for every , and the edge of weight for every level . Its size is .
First, we describe our hopset for unweighted graphs.
Four hops in unweighted graphs. Set . Every estimate used in the analysis of Section 4 is the length of a walk with , or of a walk with and . Both walks have at most 4 edges of (see Figure 1). We obtain:
Reminder of Theorem 14. There is a 4-hops -approximation hopset of size for unweighted graphs.
For weighted graphs, we have three hopsets.
Three hops in weighted graphs. Let contain together with the entries of the table of Algorithm 2. Every estimate in the analysis of Section 5 is then the length of a walk with at most 3 hops (see Figure 4), so the stretch guarantee is unchanged. We obtain:
Reminder of Theorem 15. There is a 3-hops -stretch hopset of size for weighted graphs.
Five hops in weighted graphs. We use the same hopset as in the unweighted case and adapt the analysis of Section 4. There, the connecting vertex of Claim 5.2 is obtained by rounding the ideal split point on to a vertex, and this rounding is the source of the additive 3 in (1). In a weighted graph, we do not round. If and ,^9 we take the edge of that contains the ideal split point, as in Claim 10.1, so that and . Applying Claim 5.3 at , and symmetrically at , gives and , and hence the walk
of length at most . This walk has 5 hops: four hopset edges and the edge of . Since the condition is now instead of (1), the numerical argument of Section 4 (the
^9Otherwise, the first claim in the proof of Lemma 5 gives a walk of the required length with 2 hops.
proof of Lemma 6 with , using the condition in place of , which turns the bounds and into and gives stretch without the additive .
Reminder of Theorem 17. There is a 5-hops k-stretch hopset of size for weighted graphs.
Four hops in weighted graphs. The edge and the hop from to can be merged into a single hopset edge. Let contain and, for every oriented edge of and every , the edge of weight . There are such edges. The walk above becomes , which has 4 hops and the same length, and we obtain:
Reminder of Theorem 16. There is a 4-hops k-stretch hopset of size for weighted graphs.
8 Generalizing to -PSP
In this section, we extend the results of the previous sections to the more general -PSP problem, which has sources for the pairs of query vertices, i.e., the input is a set of pairs together with a set of size such that for every pair .
Notice that if , then this problem is exactly -PSP. In this section, we show that if , then improved algorithms are obtained. In fact, essentially every prescribed-pairs problem studied in this paper is a special case of -PSP: -PSP is -PSP, -PSP is -PSP, and -PSP is -PSP, since one can always take to contain one endpoint of every pair. The -shortest paths problem with and is -PSP, and MSSP with a set of sources is -PSP.
Our extension to -PSP relies on the following idea, previously used in the parameterized approximate distance oracles of [KR26a, RTZ05]. Instead of a hierarchy , each sampled with probability , we let be the set of sources of the queries. The rest of the hierarchy is then obtained by sampling every vertex of with probability .
The set need not be given as part of the input, and a near-optimal one can be computed in linear time. A smallest set that hits every pair of is exactly a minimum vertex cover of the graph . Computing it is NP-hard, but a 2-approximation is enough for our purposes. We scan the pairs of in an arbitrary order and, whenever we encounter a pair that is not yet hit by , we add both and to . The pairs added this way are pairwise disjoint, and every hitting set contains an endpoint of each of them. Hence, , and the whole computation takes time. As enters our bounds only through and , this loses a factor of at most in the running time.
We then use the construction of [TZ05] to compute the bunches with respect to the new hierarchy in time, and continue to run the algorithms of the previous sections with respect to the new hierarchy and bunches. For the new hierarchy, we have for every .
Notice that for an input pair , we may assume without loss of generality that , and hence and . The only difference from the previous sections is therefore that the hierarchy no longer starts at . The analysis tools of the previous sections, for both weighted and unweighted graphs, are carefully designed so that their assumptions involve only the increments and , which are unchanged by subtracting the initial heights, and, in the weighted case, differences between heights at the two endpoints, while their conclusions bound by plus an additive term. Therefore, running the same algorithms with the new hierarchy adds at most to the estimate in the unweighted case. In the weighted case, the differences between the two endpoints require the additional adjustment below, which adds at most to the estimate. We therefore obtain the following two theorems for the general -PSP problem:
Reminder of Theorem 7. There is an -time -approximation algorithm for -PSP in unweighted undirected graphs.
Proof. As discussed above, since and , the stretch analysis of Section 4, which relies only on the increments and through the Mixed-Level Growth Lemma (Lemma 5) and the numerical optimization of Lemma 6, follows with an additive in the estimate. In more detail, the proof of Lemma 5 uses only Lemma 2 and the triangle inequality, so it holds for any hierarchy, and its condition involves only and . In Section 4, the numerical argument writes and , which uses . In general, and . Hence, both bounds used there, the bound of Lemma 5 and the last-level bound , exceed the expressions bounded in Lemma 6 by at most . This gives the -approximation.
It remains to bound the running time. Constructing the bunches takes time. Constructing takes time. Querying a pair takes time. Therefore, querying all pairs takes time. Thus, the total running time is , as required.
Reminder of Theorem 6. There is an -time -approximation algorithm for -PSP in weighted undirected graphs.
Proof. As discussed above, since and , the stretch analysis of Section 5 follows with an additive in the estimate. In more detail, we apply the numerical optimization of Lemma 11 to the heights for , so that . This replacement cannot increase the increments and , or any positive difference between heights at the two endpoints. Therefore, whenever the condition of the Two-Level Growth Lemma (Lemma 9) or the Long-Short Growth Lemma (Lemma 10) holds for the modified heights, it also holds for the original heights. Since , all the bounds used in Section 5 exceed their expressions in the modified heights by at most . This gives the -approximation.
It remains to bound the running time. Constructing the bunches takes time. Constructing takes time, where the sum is over the oriented edges of . Querying a pair takes time. Therefore, querying all pairs takes time. Thus, the total running time is , as required.
Instantiating Theorems 6 and 7 with the special cases listed above recovers all of our prescribed-pairs bounds. Taking together with and , respectively, recovers the running times of Theorems 3 and 4, where the additive terms and , respectively, are not paid since implies . Taking gives the improved -PSP bounds of Theorems 12 and 13 for , taking and gives Theorems 8 and 9 for -SP, and taking and gives MSSP in time for weighted graphs and in time for unweighted graphs.
References
[ABD+25] Vikrant Ashvinkumar, Aaron Bernstein, Chengyuan Deng, Jie Gao, and Nicole Wein. Low sensitivity hopsets. In 16th Innovations in Theoretical Computer Science Conference (ITCS 2025), volume 325 of Leibniz International Proceedings in Informatics (LIPIcs), pages 13:1–13:23. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2025.
[ABF23] Amir Abboud, Karl Bringmann, and Nick Fischer. Stronger 3-sum lower bounds for approximate distance oracles via additive combinatorics. In Barna Saha and Rocco A. Servedio, editors, Proceedings of the 55th Annual ACM Symposium on Theory of Computing, STOC 2023, Orlando, FL, USA, June 20-23, 2023, pages 391–404. ACM, 2023.
[ABKZ22] Amir Abboud, Karl Bringmann, Seri Khoury, and Or Zamir. Hardness of approximation in p via short cycle removal: cycle detection, distance oracles, and beyond. 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 1487–1500. ACM, 2022.
[ABP18] Amir Abboud, Greg Bodwin, and Seth Pettie. A hierarchy of lower bounds for sublinear additive spanners. SIAM J. Comput., 47(6):2203–2236, 2018.
[ACIM99] D. Aingworth, C. Chekuri, P. Indyk, and R. Motwani. Fast estimation of diameter and shortest paths (without matrix multiplication). SIAM Journal on Computing, 28(4):1167–1181, 1999.
[AG11] Ittai Abraham and Cyril Gavoille. On approximate distance labels and routing schemes with affine stretch. In David Peleg, editor, Distributed Computing - 25th International Symposium, DISC 2011, Rome, Italy, September 20-22, 2011. Proceedings, volume 6950 of Lecture Notes in Computer Science, pages 404–415. Springer, 2011.
[AG13] Rachit Agarwal and Philip Brighten Godfrey. Distance oracles for stretch less than 2. In Sanjeev Khanna, editor, Proceedings of the Twenty-Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2013, New Orleans, Louisiana, USA, January 6-8, 2013, pages 526–538. SIAM, 2013.
[Aga14] Rachit Agarwal. The space-stretch-time tradeoff in distance oracles. In Andreas S. Schulz and Dorothea Wagner, editors, Algorithms - ESA 2014 - 22th Annual European Symposium, Wrocław, Poland, September 8-10, 2014. Proceedings, volume 8737 of Lecture Notes in Computer Science, pages 49–60. Springer, 2014.
[AGH11] Rachit Agarwal, Philip Brighten Godfrey, and Sariel Har-Peled. Approximate distance queries and compact routing in sparse graphs. In INFOCOM 2011. 30th IEEE International Conference on Computer Communications, Joint Conference of the IEEE Computer and Communications Societies, 10-15 April 2011, Shanghai, China, pages 1754–1762. IEEE, 2011.
[AGH12] Rachit Agarwal, Philip Brighten Godfrey, and Sariel Har-Peled. Faster approximate distance queries and compact routing in sparse graphs. CoRR, abs/1201.2703, 2012.
[AR20] Maor Akav and Liam Roditty. An almost 2-approximation for all-pairs of shortest paths in subquadratic time. In Proceedings of the 2020 ACM-SIAM Symposium on Discrete Algorithms (SODA 2020), pages 1–11. SIAM, 2020.
[AR21] Maor Akav and Liam Roditty. A unified approach for all pairs approximate shortest paths in weighted undirected graphs. In 29th Annual European Symposium on Algorithms (ESA 2021), volume 204 of Leibniz International Proceedings in Informatics (LIPIcs), pages 4:1–4:18. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2021.
[BH23] Greg Bodwin and Gary Hoppenworth. Folklore sampling is optimal for exact hopsets: Confirming the barrier. In 2023 IEEE 64th Annual Symposium on Foundations of Computer Science (FOCS 2023), pages 701–720. IEEE, 2023.
[BK10] Surender Baswana and Telikepalli Kavitha. Faster algorithms for all-pairs approximate shortest paths in undirected graphs. SIAM J. Comput., 39(7):2865–2896, 2010.
[BP20] Uri Ben-Levy and Merav Parter. New spanners and hopsets. In Proceedings of the 31st Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2020), pages 1695–1714. SIAM, 2020.
[BS07] Surender Baswana and Sandeep Sen. A simple and linear time randomized algorithm for computing sparse spanners in weighted graphs. Random Struct. Algorithms, 30(4):532–563, 2007.
[BW23] Aaron Bernstein and Nicole Wein. Closing the gap between directed hopsets and shortcut sets. In Proceedings of the 2023 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2023), pages 163–182. SIAM, 2023.
[CC07] Sergio Cabello and Erin W Chambers. Multiple source shortest paths in a genus g graph. In Proceedings of the eighteenth annual ACM-SIAM symposium on Discrete algorithms, pages 89–97, 2007.
[CCE13] Sergio Cabello, Erin W. Chambers, and Jeff Erickson. Multiple-source shortest paths in embedded graphs. SIAM J. Comput., 42(4):1542–1571, 2013.
[CGR16] Massimo Cairo, Roberto Grossi, and Romeo Rizzi. New bounds for approximating extremal distances in undirected graphs. In Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2016, pages 363–376. SIAM, 2016.
[Che13] Shiri Chechik. Compact routing schemes with improved stretch. In Panagiota Fatourou and Gadi Taubenfeld, editors, ACM Symposium on Principles of Distributed Computing, PODC '13, Montreal, QC, Canada, July 22-24, 2013, pages 33–41. ACM, 2013.
[Che14] Shiri Chechik. Approximate distance oracles with constant query time. In David B. Shmoys, editor, Symposium on Theory of Computing, STOC 2014, New York, NY, USA, May 31 - June 03, 2014, pages 654–663. ACM, 2014.
[Che15] Shiri Chechik. Approximate distance oracles with improved bounds. In Rocco A. Servedio and Ronitt Rubinfeld, editors, Proceedings of the Forty-Seventh Annual ACM on Symposium on Theory of Computing, STOC 2015, Portland, OR, USA, June 14-17, 2015, pages 1–10. ACM, 2015.
[CHL25] Shiri Chechik, Itay Hoch, and Gur Lifshitz. New approximation algorithms and reductions for n-pairs shortest paths and all-nodes shortest cycles. In Yossi Azar and Debmalya Panigrahi, editors, Proceedings of the 2025 Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2025, New Orleans, LA, USA, January 12-15, 2025, pages 5207–5238. SIAM, 2025.
[Coh98] Edith Cohen. Fast algorithms for constructing t-spanners and paths with stretch t. SIAM J. Comput., 28(1):210–236, 1998.
[Coh00] Edith Cohen. Polylog-time and near-linear work approximation scheme for undirected shortest paths. Journal of the ACM, 47(1):132–166, 2000.
[CZ22] Shiri Chechik and Tianyi Zhang. Nearly 2-approximate distance oracles in subquadratic time. In Proceedings of the 2022 ACM-SIAM Symposium on Discrete Algorithms (SODA 2022), pages 551–580. SIAM, 2022.
[DFK+24] Michal Dory, Sebastian Forster, Yael Kirkpatrick, Yasamin Nazari, Virginia Vassilevska Williams, and Tijn de Vos. Fast 2-approximate all-pairs shortest paths. In Proceedings of the 2024 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2024), pages 4728–4757. SIAM, 2024.
[DHZ00] Dorit Dor, Shay Halperin, and Uri Zwick. All-pairs almost shortest paths. SIAM J. Comput., 29(5):1740–1759, 2000.
[DJWW22] Mina Dalirrooyfard, Ce Jin, Virginia Vassilevska Williams, and Nicole Wein. Approximation algorithms and hardness for n-pairs shortest paths and all-nodes shortest cycles. In 63rd IEEE Annual Symposium on Foundations of Computer Science, FOCS 2022, Denver, CO, USA, October 31 - November 3, 2022, pages 290–300. IEEE, 2022.
[DSDP15] Atish Das Sarma, Michael Dinitz, and Gopal Pandurangan. Efficient distributed computation of distance sketches in networks. Distributed Computing, 28(5):309–320, 2015.
[EFN18] Michael Elkin, Arnold Filtser, and Ofer Neiman. Prioritized metric structures and embedding. SIAM Journal on Computing, 47(3):829–858, 2018.
[EK13] David Eisenstat and Philip N. Klein. Linear-time algorithms for max flow and multiple-source shortest paths in unit-weight planar graphs. In Dan Boneh, Tim Roughgarden, and Joan Feigenbaum, editors, Symposium on Theory of Computing Conference, STOC'13, Palo Alto, CA, USA, June 1-4, 2013, pages 735-744. ACM, 2013.
[Elk05] Michael Elkin. Computing almost shortest paths. ACM Trans. Algorithms, 1(2):283-323, 2005.
[EM21] Michael Elkin and Shaked Matar. Deterministic PRAM approximate shortest paths in polylogarithmic time and slightly super-linear work. In Proceedings of the 33rd ACM Symposium on Parallelism in Algorithms and Architectures (SPAA 2021), pages 198-207. ACM, 2021.
[EN19] Michael Elkin and Ofer Neiman. Hopsets with constant hopbound, and applications to approximate shortest paths. SIAM Journal on Computing, 48(4):1436-1480, 2019.
[EN22] Michael Elkin and Ofer Neiman. Linear-size hopsets with small hopbound, and constant-hopbound hopsets in RNC. Distributed Computing, 35(5):419-437, 2022.
[ENW16] Michael Elkin, Ofer Neiman, and Christian Wulff-Nilsen. Space-efficient path-reporting approximate distance oracles. Theor. Comput. Sci., 651:1-10, 2016.
[HJWX24] Alina Harbuzova, Ce Jin, Virginia Vassilevska Williams, and Zixuan Xu. Improved roundtrip spanners, emulators, and directed girth approximation. In David P. Woodruff, editor, Proceedings of the 2024 ACM-SIAM Symposium on Discrete Algorithms, SODA 2024, Alexandria, VA, USA, January 7-10, 2024, pages 4641-4669. SIAM, 2024.
[HKN18] Monika Henzinger, Sebastian Krinninger, and Danupon Nanongkai. Decremental single-source shortest paths on undirected graphs in near-linear total update time. Journal of the ACM, 65(6):36:1-36:40, 2018.
[HP19] Shang-En Huang and Seth Pettie. Thorup-Zwick emulators are universally optimal hopsets. Information Processing Letters, 142:9-13, 2019.
[HXX25] Gary Hoppenworth, Yinzhan Xu, and Zixuan Xu. New separations and reductions for directed hopsets and preservers. In Proceedings of the 2025 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2025), pages 4405-4443. SIAM, 2025.
[JX23] Ce Jin and Yinzhan Xu. Removing additive structure in 3sum-based reductions. In Proceedings of the 55th Annual ACM Symposium on Theory of Computing, pages 405-418, 2023.
[Kad26] Avi Kadria. Deterministic girth approximation in weighted undirected graphs, 2026. arXiv:2610.13452.
[Kle05] Philip N Klein. Multiple-source shortest paths in planar graphs. In Proceedings of the sixteenth annual ACM-SIAM symposium on Discrete algorithms, pages 146-155, 2005.
[KP22a] Shimon Kogan and Merav Parter. Having hope in hops: New spanners, preservers and lower bounds for hopsets. In 63rd IEEE Annual Symposium on Foundations of Computer Science, FOCS 2022, Denver, CO, USA, October 31 - November 3, 2022, pages 766-777. IEEE, 2022.
[KP22b] Shimon Kogan and Merav Parter. New diameter-reducing shortcuts and directed hopsets: Breaking the barrier. In Proceedings of the 2022 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA 2022), pages 1326-1341. SIAM, 2022.
[KR25a] Avi Kadria and Liam Roditty. Compact routing schemes in undirected and directed graphs. In 39th International Symposium on Distributed Computing (DISC 2025), volume 356 of LIPIcs, pages 38:1-38:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2025.
[KR25b] Avi Kadria and Liam Roditty. New approximate distance oracles and their applications. In 36th International Symposium on Algorithms and Computation (ISAAC 2025), volume 359 of Leibniz International Proceedings in Informatics (LIPIcs), pages 43:1–43:17. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2025.
[KR26a] Avi Kadria and Liam Roditty. Faster algorithms for (2k – 1)-stretch distance oracles. In Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele Puppis, editors, 53rd International Colloquium on Automata, Languages, and Programming, ICALP 2026, Royal Holloway, University of London, Egham, United Kingdom, July 7-10, 2026, volume 374 of LIPIcs, pages 121:1–121:22. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2026.
[KR26b] Avi Kadria and Liam Roditty. Tight space bounds for pivot-based distance oracles in sparse graphs. arXiv preprint arXiv:2610.29624, 2026.
[KRQV26] Yael Kirkpatrick, Liam Roditty, Richard Qi, and Virginia Vassilevska Williams. New diameter approximations via distance oracle techniques. In 53rd International Colloquium on Automata, Languages, and Programming (ICALP 2026), volume 374 of LIPIcs, pages 127:1–127:22. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2026.
[KRS+22] Avi Kadria, Liam Roditty, Aaron Sidford, Virginia Vassilevska Williams, and Uri Zwick. Algorithmic trade-offs for girth approximation in undirected graphs. In Proceedings of the 2022 ACM-SIAM Symposium on Discrete Algorithms, SODA 2022, pages 1471–1492. SIAM, 2022.
[KRS+26] Avi Kadria, Liam Roditty, Aaron Sidford, Virginia Vassilevska Williams, and Uri Zwick. Improved girth approximation in weighted undirected graphs. SIAM Journal on Computing, 55(4):560–577, 2026.
[KRV26a] Avi Kadria, Liam Roditty, and Virginia Vassilevska Williams. Improved approximation algorithms for n-pairs shortest paths. In 34th Annual European Symposium on Algorithms, ESA 2026, L'Aquila, Italy, August 31 - September 4, 2026, LIPIcs. Schloss Dagstuhl - Leibniz-Zentrum für Informatik, 2026.
[KRV26b] Avi Kadria, Liam Roditty, and Virginia Vassilevska Williams. Tighter bounds for weighted and unweighted shortest cycle approximation. In 34th Annual European Symposium on Algorithms (ESA 2026), volume 388 of LIPIcs, pages 82:1–82:20. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2026.
[MPVX15] Gary L. Miller, Richard Peng, Adrian Vladu, and Shen Chen Xu. Improved parallel algorithms for spanners and hopsets. In Proceedings of the 27th ACM Symposium on Parallelism in Algorithms and Architectures (SPAA 2015), pages 192–201. ACM, 2015.
[NS22] Ofer Neiman and Idan Shabat. A unified framework for hopsets. In 30th Annual European Symposium on Algorithms (ESA 2022), volume 244 of Leibniz International Proceedings in Informatics (LIPIcs), pages 81:1–81:13. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2022.
[Pet09] Seth Pettie. Low distortion spanners. ACM Transactions on Algorithms, 6(1):7:1–7:22, 2009.
[PR13] Ely Porat and Liam Roditty. Preprocess, set, query! Algorithmica, 67(4):516–528, 2013.
[PR14] Mihai Pătrașcu and Liam Roditty. Distance oracles beyond the thorup-zwick bound. SIAM J. Comput., 43(1):300–311, 2014.
[Rod23] Liam Roditty. New algorithms for all pairs approximate shortest paths. In Barna Saha and Rocco A. Servedio, editors, Proceedings of the 55th Annual ACM Symposium on Theory of Computing, STOC 2023, Orlando, FL, USA, June 20-23, 2023, pages 309–320. ACM, 2023.
[RS25] Liam Roditty and Ariel Sapir. Additive, near-additive, and multiplicative approximations for APSP in weighted undirected graphs: Trade-offs and algorithms. arXiv preprint arXiv:2509.04640, 2025.
[RTZ05] Liam Roditty, Mikkel Thorup, and Uri Zwick. Deterministic constructions of approximate distance oracles and spanners. In Luís Caires, Giuseppe F. Italiano, Luís Monteiro, Catuscia Palamidessi, and Moti Yung, editors, Automata, Languages and Programming, 32nd International Colloquium, ICALP 2005, Lisbon, Portugal, July 11-15, 2005, Proceedings, volume 3580 of Lecture Notes in Computer Science, pages 261–272. Springer, 2005.
[TZ01] Mikkel Thorup and Uri Zwick. Compact routing schemes. In Arnold L. Rosenberg, editor, Proceedings of the Thirteenth Annual ACM Symposium on Parallel Algorithms and Architectures, SPAA 2001, Heraklion, Crete Island, Greece, July 4-6, 2001, pages 1–10. ACM, 2001.
[TZ05] Mikkel Thorup and Uri Zwick. Approximate distance oracles. J. ACM, 52(1):1–24, 2005.
[TZ06] Mikkel Thorup and Uri Zwick. Spanners and emulators with sublinear distance errors. In Proceedings of the Seventeenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2006, Miami, Florida, USA, January 22-26, 2006, pages 802–809. ACM Press, 2006.
[Wul12] Christian Wulff-Nilsen. Approximate distance oracles with improved preprocessing time. In Yuval Rabani, editor, Proceedings of the Twenty-Third Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2012, Kyoto, Japan, January 17-19, 2012, pages 202–208. SIAM, 2012.
[Wul13] Christian Wulff-Nilsen. Approximate distance oracles with improved query time. In Sanjeev Khanna, editor, Proceedings of the Twenty-Fourth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2013, pages 539–549. SIAM, 2013.
A Numerical optimization lemmas
A.1 Solving the optimization problem for stretch
In this section, we prove the following lemma, used in the proof of Theorem 4.
Reminder of Lemma 6. Let and be integers, and let be a real number. Let be nonnegative integers for every . Then
We first prove a normalized version of the lemma, in which all increments lie in , and then derive Lemma 6 from it by capping and scaling.
Claim 14.1. Let and , and let . Write , and set . Then either , or , or there are with such that
Proof. We call a pair of indices a crossing if . We may assume that both sequences are nondecreasing: replace each entry by the maximum of all entries up to its position. Write for the modified entries and for their prefix sums. Complete sums can only increase, so the first two alternatives for the modified sequences imply the same alternatives for the original sequences. For a crossing in the modified sequences, choose and attaining the running maxima, so and . Then
Thus the third alternative also transfers to the original sequences. We henceforth work with the modified sequences, retaining the original notation.
Suppose the conclusion fails. In particular, and . If every pair with satisfied , then summing over would give
a contradiction. Hence, there is a crossing with .
Let be the minimum value of over all crossings. Thus . If , then is a crossing and , a contradiction. We may therefore assume . Minimality gives
Summing, we obtain
By symmetry, assume , so .
If there is a crossing with and . Since both sequences are nondecreasing, their prefix averages are nondecreasing. Therefore,
a contradiction.
Otherwise. Every crossing with satisfies . Choose such a crossing with as large as possible. For every , we have , so this choice implies . Summing these inequalities gives
Using the nondecreasing prefix averages of the x-sequence, we obtain
(1)
Since each is at most 1 and ,
Since , we can substitute this lower bound into (1), obtaining
The last inequality uses and . This is again a contradiction.
Proof of Lemma 6. Let . The entries may exceed , so we first cap them. For every , let and . We apply Claim 14.1 with to the sequences and , whose entries lie in . Since the entries are integers, a crossing of the normalized sequences implies . For a pair with , we call its value. Multiplying the resulting bounds by , we obtain one of the following two cases.
The first two alternatives. We have or . In the first case, if , then . Hence, in both cases,
Suppose first that . If no entry of the -sequence was capped, then . Otherwise, let be the smallest index with . Then , so the pair satisfies . Since and no entry before was capped,
and the pair gives a value of at most . The case is analogous: if no entry of the -sequence was capped, then , and otherwise the smallest capped index gives the pair , whose value is at most .
The third alternative. There are with and
Since and , the pair also satisfies . If no entry with and no entry with was capped, the prefix sums are unchanged, and the pair gives a value of at most
Otherwise, some with or some with was capped. Since the bound on the prefix sums is symmetric, we may assume the former. Let be the smallest such index. Then , so the pair satisfies , and
Hence the pair gives a value of at most .
In every case, the required minimum is at most , as claimed.
A.2 The case
Reminder of Lemma 11. Let with , and for every let and . Then
Proof. Let denote the minimum in the statement. We prove the bound . The case is immediate. Also, if , then . Thus assume that and .
We will choose a cutoff index q and prove
The first inequality follows from the two-level terms in the minimum. To obtain the second, we encode the tail of one sequence and the prefix of the other by intervals, and use the long-short terms to bound the lengths of overlapping intervals.
Replace each by and each by , and recompute the increments. We retain the same notation, keeping fixed as the original minimum. Thus .
Claim 14.2 (Local restrictions). For and ,
and the same implication holds after exchanging and . Moreover, for ,
Every increment and every pair of consecutive increments is at most 2, and .
Proof. If the hypothesis of (1) holds after truncation, both prefixes are below Q and hence unchanged. A violation of its conclusion would also have held before truncation, since increments only decrease. It would therefore make a feasible objective below Q, contradicting the definition of the minimum.
Similarly, if , these prefixes are unchanged. Both two-level objectives at index are at most , so neither of their defining strict conditions can hold. Hence
Adding these inequalities proves (2).
Every positive capped increment starts at . For , applying (1) with gives . The first increment is bounded by assumption, and the same argument applies to .
For , if , apply (1) at to obtain . If , then , so the same bound follows from . The argument for is identical.
Finally, , so (1) at (2,1) gives , and therefore .
We now locate the cutoff. Let be the largest index such that , and write
Claim 14.3 (The cutoff index).
Proof. By Claim 14.2, , whereas . Thus .
For every , we have . Hence (2) shows that every two levels add at most 2 to the combined prefix sum. Starting from on the even indices and on the odd indices gives
Since , applying (1) at gives . In particular, . The maximality of therefore implies
which yields .
Next, we compare the remaining growth of X with the accumulated growth of Y. By symmetry, assume that . Then
We encode these two quantities by intervals, with a loss of at most 1 in their total length.
The long-short restriction involves two consecutive increments of X and one increment of Y. Accordingly, define
Thus and . The midpoint endpoints make the consecutive, while the reflection of the will make overlap imply the prefix condition in (1).
Claim 14.4 (The interval representation). Each family has disjoint interiors, and every lies inside . Moreover,
Every has length at most 1, and positive overlap of and implies
Proof. The intervals within each family are consecutive. Their unions are
Since , the left endpoint of the second union is greater than . Since , its right endpoint is at most the right endpoint of the first union. This proves the containment. The threshold in the definition of was chosen to ensure precisely this property.
Summing the lengths gives
using , , and .
Claim 14.2 gives . If and overlap in positive length, the left endpoint of is below the right endpoint of , so
Since , this implies
Applying (1) at yields
as required.
The remaining task is to turn the total length in Claim 14.4 into a bound on the number of intervals. We count the lengths of the two families separately: a point in their overlap contributes twice to the total length.
Claim 14.5 (Counting the intervals).
Proof. We assign weights that provide at least 8 per unit of length in each family. Thus a point covered by both families must receive density at least 16.
Distribute weight 9 uniformly over each nonempty , and weight 2 uniformly over each nonempty . At a point covered only by an , the density is . On a positive overlap, (4) and Cauchy–Schwarz give
Apart from endpoints, each point belongs to at most one interval from each family. There are no points covered only by a , because every lies inside . Hence the total weight is at least
There are intervals and intervals , so the assigned weight is at most . This proves the claim.
Claim 14.4 provides a total length of at least Q - 1, and Claim 14.5 bounds the weight needed to cover that length. The resulting budget is , so the lower bound on q from Claim 14.3 now gives
Therefore , and hence