Faster Algorithms for -Stretch Distance Oracles
Abstract
The seminal distance oracles of Thorup and Zwick [STOC 2001, JACM 2005] provide optimal stretch/space tradeoffs. However, their construction time is not optimal, and they posed the question of whether a faster construction time is possible (especially for small ). In this paper, we present the first improvement upon their construction algorithm in graphs that are not super sparse, i.e., when , for any . Moreover, our construction improves upon the -time construction of Baswana and Kavitha [FOCS 2006, SICOMP 2010], for every . By achieving the first subquadratic construction for , we resolve the open problem posed by Wulff-Nilsen [SODA 2012] of whether such subquadratic-time constructions exist.
Wulff-Nilsen [SODA 2012] targeted nearly linear construction times and presented algorithms running in time, which is near-linear whenever the graph density exceeds the threshold . We obtain improved bounds on for all , and thus expand the regime of graph densities for which nearly linear construction times are achievable.
In addition, for unweighted graphs, we present several new algorithms for constructing -oracles that improve upon the results of Baswana, Gaur, Sen, and Upadhyay [ICALP 2008].
Our results are achieved through the development of several new algorithmic tools, which may be of independent interest. One of our main technical contributions is a hierarchy of parameterized distance oracles, which plays a central role in our fast construction algorithms.
Keywords and phrases:
Fine-grained complexity, Graph algorithms, shortest cycle, girth approximationsCategory:
Track A: Algorithms, Complexity and GamesFunding:
Liam Roditty: Supported in part by BSF grants 2016365 and 2020356.Copyright and License:
2012 ACM Subject Classification:
Theory of computation Approximation algorithms analysis ; Theory of computation Shortest paths ; Mathematics of computing Graph algorithmsEditors:
Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele PuppisSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl β Leibniz-Zentrum fΓΌr Informatik
1 Introduction
In their seminal work111Winner of the 20-year Test-of-Time award of STOC 2021. on distance oracles, Thorup and Zwick [32] presented an algorithm that constructs in expected222Later, Roditty, Thorup, and Zwick [31] derandomized the construction. time, for any integer , a -stretch distance oracle that uses space and answers distance queries in time. Many different aspects of distance oracles, including fast construction algorithms, have been studied since the introduction of distance oracles [29, 20, 22, 23, 18, 34, 9, 27, 28, 4, 3, 24, 17, 35].
Assuming the ErdΕs girth conjecture, the -stretch / -space tradeoff established in [32] is optimal. Chechik [15, 16] improved the query time to . Therefore, the main open problem regarding distance oracles that remains is improving its construction time. In the words of Thorup and Zwick [32]:
βIt remains an interesting open problem, however, to reduce the preprocessing times of small stretch oracles.β
Thorup and Zwick [32]
The construction algorithm of Thorup and Zwick [32] is super-quadratic (in ) whenever . Baswana and Kavitha [9] addressed this problem and presented an construction-time algorithm, for every . In light of the quadratic time algorithm of Baswana and Kavitha [9], Wulff-Nilsen [34] considered the following problem.
Problem 1.
For graphs with , for , for which values of , does there exist an , for , time algorithm that constructs a -stretch distance oracle with query time333 omits a polylogn factor and space?
Wulff-Nilsen [34] presented an time construction algorithm, which is truly subquadratic time for every . Therefore, this resolves Problem 1 for all . Similar to Thorup and Zwick, Wulff-Nilsen suggested focusing on small stretch oracles and asked whether subquadratic time algorithms exist for smaller values of .
In this paper, we provide an almost complete answer to Problem 1 by presenting a truly subquadratic-time construction algorithm for every , leaving only the case that open444We highlight that solving 1 for and achieving a -stretch distance oracle in truly subquadratic time β even without imposing space constraints β would be a significant breakthrough. Such a result would improve upon the long-standing -time -stretch all-pairs shortest paths (APSP) algorithm of Cohen and Zwick [19], and would be a foundational advancement in the development of approximation algorithms for .. We achieve a running time of , which for graphs with , is truly subquadratic time of . Moreover, this is the first improvement over the construction time of Thorup and Zwick [32] in graphs with edges, for any .
Theorem 1.
Let be a weighted undirected graph and be an integer. There is an time algorithm that constructs a -stretch distance oracle that uses -space and answers distance queries in time.
After breaking the quadratic time barrier for every , we shift our focus to achieving optimal555 construction time is required due to a simple reduction to -connectivity. linear construction time, as formalized in the following problem.
Problem 2.
For every , what is the smallest value for which a -stretch distance oracle with query time and space complexity can be constructed in time?
A running time of is nearly linear for graphs where , and is therefore optimal (up to logarithmic factors) for such graphs. In other words, Problem 2 asks: what is the sparsest graph for which it is possible to construct a -stretch distance oracle with query time and space in almost linear time?
There are two approaches to attack Problem 2. One approach is to prove a lower bound on the value of . Jin and Xu [25] proved that time is required for constructing a -stretch distance oracle, for graphs in which , conditioned on the SUM conjecture. Independently, and also conditioned on the SUM conjecture, Abboud, Bringmann, and Fischer [3] proved that time is required. These two results rule out linear-time construction for graphs with , which implies that .666Abboud, Bringmann, Khoury, and Zamir [4] previously proved that construction time is required, for a small constant .
In addition, Jin and Xu [25] proved that time is required for constructing a -stretch distance oracle, for graphs in which , ruling out linear time construction for graphs with , and therefore showing that , for every .
Another approach to attack Problem 2 is to design a faster construction algorithm which improve the upper bound on . Wulff-Nilsen [34] presented two construction algorithms. The first algorithm with running time was discussed above, and the second algorithm has running time. Combining these two algorithms with the -time algorithm of Baswana and Kavitha [9] we get:
In this paper, we improve the construction time of the Wulff-Nilsen [34] algorithms and present two new construction algorithms, as presented in the following two theorems.
Theorem 2.
Let be a weighted undirected graph and let be an integer. There is an time algorithm that constructs a -stretch distance oracle that uses -space and answers distance queries in time.
Theorem 3.
Let be a weighted undirected graph and be an integer. There is an time algorithm that constructs a -stretch distance oracle that uses -space and answers distance queries in time.
Combining these two algorithms, we significantly improve upon the current state of the art and obtain the following upper bound on :
In Table 1, we summarize our new construction algorithms for weighted undirected graphs and compare them to the previously known results. In Table 2 and Figure 2, we compare our new results on the sparsest graphs for which a linear-time construction algorithm exists with the prior work of [9, 34].
Our pursuit of faster construction algorithms leads us to develop several novel tools. Among them are new parameterized distance oracles. Parameterized distance oracles were first introduced by Roditty, Thorup, and Zwick [31]. Given a set as a parameter, they presented an -time construction algorithm that builds a -stretch distance oracle with space, supporting queries only for vertex pairs .
One of our new tools is a parameterized distance oracle, which is a natural generalization of the parameterized distance oracle of [31]. Our parameterized distance oracle is constructed in the same running time, uses the same amount of space. The oracle supports queries for every in , rather than in as [31], at the cost of adding to the estimate, where is the distance from to . Notice that if , then , and the stretch is as in [31].
The main technical contribution of this paper is a new algorithmic tool called hierarchical distance oracles, which is composed of a hierarchy of parameterized distance oracles. This construction consists of such oracles, each built on a distinct subgraph of and parameterized by a different set .
Using our new hierarchical distance oracle we obtain our -time algorithm for constructing a -stretch distance oracle that uses space, mentioned above. We remark that this improves upon the -construction time of Thorup and Zwick [32], for graphs with edges.
In addition, we consider unweighted graphs. An estimation of is an -approximation if . -approximations were extensively studied in the context of graph spanners, emulators, and distance oracles. (For more details see for example [21, 33, 10, 14, 13, 30, 1, 2, 6, 5, 18, 12, 27, 7]).
Baswana, Gaur, Sen, and Upadhyay [8] considered estimations with an additive error, to obtain faster construction-time algorithms for distance oracles. They studied the following problem.
Problem 3.
In unweighted undirected graphs, for every and , what is the smallest value , for which a -approximation distance oracle with query time that uses space can be constructed in time?
Baswana, Gaur, Sen and Upadhyay [8] presented an algorithm for constructing -approximation distance oracle that uses space, for . The algorithm runs in time. For , they presented an algorithm that runs in time and constructs -approximation distance oracle that uses space.
Combining these algorithms with the construction of Wulff-Nilsen [34] we get that the current state of the art for Problem 3 is:
In this paper, we improve the results of Baswana, Gaur, Sen, and Upadhyay [8] and present three new construction algorithms. The first construction algorithm runs in and constructs a -approximation distance oracle, improving the construction time of [8], for every . The second algorithm runs in time and constructs a -approximation distance oracle. The third algorithm runs in time and constructs a -approximation oracle. Combining these three algorithms, we significantly improve upon the current state of the art and obtain the following values for :
In addition, we present an time algorithm for constructing a -distance oracle, improving the stretch of the time algorithm of [34] that constructs an -distance oracle.
The rest of this paper is organized as follows. In the next section, we present some necessary preliminaries. In Section 3, we overview our main results and techniques. In Section 4 we present our new tools, and specifically in Section 4.3 we present our new hierarchical distance oracle. In Section 5 we present our construction algorithms for weighted graphs, in the full version [26], we then present the new construction algorithms for unweighted graphs. For convenience, in Appendix A we include tables and graphs that summarize all the theorems.
2 Preliminaries
Let be an undirected graph with vertices and edges. Throughout the paper, we consider unweighted and weighted graphs with non-negative real edge weights. Let , we denote as the distance between and in . Let be the shortest path between and . Let be the neighbors of and let be the degree of .
Let . The distance between and is the distance between and the closest vertex to from , that is, . We denote with , and when is clear from the context, we write . Let (ties are broken in favor of the vertex with a smaller identifier). Let . Let be the set of edges incident to whose weight is at most , that is . Let and . See Figure 1 for an illustration.
The following lemmas are standard results and are included here for completeness.
Lemma 4.
Let be a weighted undirected graph. Given a non-empty subset , and can be computed in time for all vertices .
Proof.
Let . Running Dijkstra from in computes , and identifies , the second vertex in , for every .
Lemma 5.
Let be a weighted undirected graph and let be a non-empty set, the graph can be computed in time.
Proof.
Using Lemma 4, we obtain for every in time. In time we iterate every edge and remove it if .
Baswana and Kavitha [9] proved the following useful lemma on the graph .
Lemma 6 ([9]).
Let be a weighted undirected graph and let be a non-empty set. For any two vertices , if then . If is obtained by picking each vertex independently with probability , then has expected size .
When Throughout the paper, we occasionally distinguish between the case that and the case that . Next, we prove a useful bound on and when .
Lemma 7.
Let be a weighted undirected graph. If , then
Proof.
Since there exists an edge such that . Wlog, we assume that . By the definition of , the fact that implies that Since , we have Moreover, by the triangle inequality for , we get that By combining these inequalities, we get:
Where the equality follows from the fact that , as required. Using symmetric arguments, we can also get that .
For a real value , an -stretch spanner of is a subgraph of such that for every , . An -approximation spanner of is a subgraph such that for every , . In the next lemma, we describe the spanner construction that we use in our algorithms.
Lemma 8 ([11]).
For any integer , for a weighted graph , a -spanner with edges can be computed in time.
In the following lemma, we summarize the properties of the distance oracle construction algorithm as presented in [32].
Lemma 9 ([32]).
There is an -space -stretch distance oracle with query time. The distance oracle is constructed in expected time.
3 Overview
This section provides an overview of our construction algorithms and the key new tools we developed. To put our contribution in context, we begin by describing the framework underlying both construction algorithms of Wulff-Nilsen [34]. This framework consists of the following three steps:
-
(Step 1)
Sample a set and create an oracle that upon a query on produces .
-
(Step 2)
Compute a spanner .
-
(Step 3)
Create an oracle that upon a query on produces .
The distance oracle query of this framework returns . Using this framework, Wulff-Nilsen obtained an construction-time algorithm as follows. In (Step 1) is constructed. In (Step 2) a -spanner from Lemma 8 is computed. In (Step 3) is constructed.
Next, we discuss the new main techniques that allow us to improve (Step 1). Notice that there is a tradeoff between and . When is small, (Step 1) becomes faster and increases, resulting in a slower (Step 3). Given this tradeoff, the key to obtaining faster construction algorithms lies in the following optimization problem:
Problem 4.
For every , what is the densest graph for which a -stretch distance oracle with query time can be constructed in time?
Thorup and Zwickβs [32] construction algorithm, which is used by Wulff-Nilsen for (Step 1), solves Problem 4 for graphs with edges. We improve the construction algorithm of [32], for every and solve Problem 4 for graphs with edges.
To obtain this improvement, we develop a new hierarchy of parameterized distance oracles, which we denote with hADO (see Theorem 18). The hierarchical distance oracle uses our new parameterized distance oracle, which we denote with (see Lemma 13).
To understand how hADO works, we first describe parametrized distance oracles. Let . Roditty, Thorup, and Zwick [31] presented an -time construction algorithm for constructing a -stretch distance oracle that uses space and supports queries for vertex pairs . Our new parameterized distance oracle, , is a generalization of the parameterized distance oracle of [31]. is constructed at the same time, uses the same space and query time, and supports queries for vertex pairs rather than , and returns an estimate satisfying:
Notice that if then and , as in [31]. (For more details, see Section 4.2.)
The goal of the hADO is to compute distance oracles on denser graphs. To this end, we use a hierarchy of graphs that starts with sparse graphs and ends with denser graphs. Let and let , for some set , be the first graph in the hierarchy. The main observation is that if we already know that then, by Lemma 7, we have .
This allows us to consider the denser graph , while maintaining the same stretch and running time by computing . This solves the case in which . If by Lemma 7 we have that and we continue the process by computing . We continue this process for levels, until two consecutive steps yield the same asymptotic density.
More formally, the hierarchical distance oracle hADO works as follows. Let be a set of size , and construct . Let . For every , construct , (roughly speaking, we use since the first level is the ββ set, this is required to get the desired stretch guarantee), where is a random set of size and .777Notice that . Therefore and . The query of hADO returns .
The construction time of hADO is . To see this notice that constructing takes time, and since we get .
For every , where , we have that . To see that, let be the first index for which . Since , it follows from Lemma 7 that , thus, since was constructed with parameter we get . (See Lemma 17 for a complete proof.)
Our new hierarchical distance oracle, hADO, obtains a truly subquadratic construction algorithm for every , even without using the three-step framework presented above. Roughly speaking, the construction algorithm works as follows. Let be the solution for the equation . One can verify that .
We construct . In the hierarchy, we have that . Since we can replace with without affecting the construction time. Since for every , we obtain a -stretch distance oracle. The construction time of this distance oracle is (See Lemma 19). We remark that this is truly subquadratic since for we get a running time of , which is truly subquadratic for every .
Next, we overview our improvement in the regime of linear construction-time algorithms. To improve the previous results, we use the framework described above and improve each step of the three-step framework as follows: In (Step 1) we use as opposed to as in [34]. This enables us to estimate distances in instead of . In (Step 2) we compute a -spanner as in [34]. However, we augment with edges between and of weight for every . This enables us to bound with instead of as in [34].
For (Step 3) we develop an additional parameterized distance oracle, (see Lemma 14), that is constructed in time, the same running time as , but uses space which is significantly less space than the space required by . The space reduction comes at a cost of supporting queries only for vertex pairs in . In (Step 3) we use instead of as in [34].
These improvements allows us to reduce the construction time of [34] to and the construction time of [34] to . (See Sections 5.3 andΒ 5.2.)
By applying our new techniques to unweighted graphs and allowing a small additive error, we can further improve the construction time. In particular, among our results for unweighted graphs, we obtain a construction algorithm that in time constructs a -approximation distance oracle, improving the of Baswana, Gaur, Sen, and Upadhyay [8], for every .
We remark that all of our construction algorithms can be de-randomized using the methods presented by Roditty, Thorup, and Zwick [31] at a logarithmic cost.
4 Tools
In this section, we develop our new techniques that we later use in our fast construction algorithms presented in Sections 5 and our new the unweighted construction algorithms in the full version [26]. We begin by proving several useful properties of the classical oracle of Thorup and Zwick [32] that are used by our parameterized distance oracles, presented right afterwards. The main new technical contribution, our new hierarchical distance oracle, is presented in the last part of this section, see Section 4.3.
4.1 Properties of the classical distance oracle of [32]
In this section, we discuss the internals and some properties of the Thorup and Zwick distance oracle [32], which are then applied to our parameterized distance oracles.
Given an integer parameter , we can compute in time vertex sets , such that , for every . Let and let . Let be the closest vertex to from the set , for every . For every , let the bunch be the set . Let . Let and let .
Lemma 10 ([32]).
The size of is , whp (with high probability888We say that an event occurs with high probability (whp) if it occurs with probability at least for some constant , where is the size of the input (e.g., the number of vertices or edges in the graph). ) and the cost of computing , for every , is whp.
Next, for completeness, we describe the query of [32] (ADO.Query). Later, we generalize its correctness proofs, and this generalization helps us to achieve the oracles of Section 4.2.
The procedure ADO.Query gets as an input , and using their bunches gives an estimation . Let be . For , if return , otherwise swap and and continue iterating the for-loop. A pseudo-code for ADO.Query is presented in Algorithm 1.
Let be . The following lemmas prove properties of , which generalizes the proof of [32].
Lemma 11.
Proof.
Since , we have that . Thus, , where the last inequality follows from the triangle inequality. Using symmetrical arguments, we have that , as required.
Lemma 12.
For every integer , one of the following holds.
Proof.
Wlog (without loss of generality), assume that . We divide the proof into two cases. The case where , and the case where . Consider the case where . In this case, the value of is saved in the distance oracle. From the triangle inequality it follows that . Therefore, we have that . Since we get that , as required.
Consider now the case that . From the definition of it follows that . Since , we get that , and thus , as required.
4.2 Parameterized distance oracles
A parameterized distance oracle is constructed with respect to a special input set . Roditty et al. [31] presented an algorithm that constructs such a -distance oracle in time. The distance oracle uses space and answers distance queries only for vertex pairs in time.
In this section, we present two new parameterized distance oracles used in our fast constructions. In the first parameterized distance oracle, the query supports vertex pairs from . In the second parameterized distance oracle, the query supports vertex pairs only from .
First, we generalize the parameterized distance oracle of [31], and extend the query to support vertex pairs from , as follows. For every the query returns an estimation . Notice that when we have thus , and , as in the distance oracle of [31]. Formally:
Lemma 13.
Let and let . There is an -space distance oracle that given two vertices , returns in time an estimation such that . The distance oracle is constructed in time.
Proof.
The main idea behind our parameterized distance oracle is to construct the standard ThorupβZwick hierarchy [32], but to skip the computation related to the set (), that is, we do not compute for every . By omitting this step, we obtain a faster construction time, at the cost of increasing the stretch by an additional term of . Formally, the construction proceeds as follows.
Let , , . For every the set is a random set such that . We let for every . As presented in [31], we compute for every in time in order to save for every and the sets . From Lemma 10, we have that , thus, the distance oracle uses space.
The query of the distance oracle returns . To prove its correctness, we first prove by induction for every that either or .
For , since we get that and the claim holds. Next, we assume the claim holds for and prove the claim for . From the fact that the claim holds for , we get that either
or
If then and the claim holds. Otherwise, we have that
From Lemma 12 it follows that either
Since we get that either
as required.
We complete the proof since for we have that since does not hold since and therefore .
Next, we present the second parameterized distance oracle that supports queries only between vertices from . Notice that this oracle uses much less space than the first oracle.
Lemma 14.
Let and let . There is an -space distance oracle that given two vertices , returns in time an estimation such that . The distance oracle is constructed in time.
Proof.
The construction and the query are the same as in the distance oracle from Lemma 13. However, instead of saving , for every and , we save only for every . Thus, the space is . The correctness of the query follows from the fact that only uses the bunches of and . Thus, if then we have the information needed in .
4.3 A new hierarchy of distance oracles
In this section, we present a new distance oracle composed of a hierarchy of distance oracles. The distance oracle computes a set . The query of the distance oracle guarantees a -stretch for distances in .
The distance oracle is constructed as follows. We get as an input a graph and two parameters and , where and . First, we compute a random set such that and construct .
Next, for every , we compute a random set such that , where , and construct .
Our distance oracle stores the distance oracle and the distance oracles , for every . The construction algorithm is presented in Algorithm 2. The query algorithm returns
In the next lemma, we analyze the running time of the construction algorithm.
Lemma 15.
The distance oracle is constructed in time.
Proof.
Using Lemma 6 and the fact that we get that . Thus, constructing takes time.
For every , since , it follows from Lemma 6 that and constructing takes time. By definition , thus, we get that the construction time is for every . In addition, computing takes time, for every . Since we get that the running time is , as required.
Next, we analyze the space used by the distance oracle.
Lemma 16.
The distance oracle uses space.
Proof.
From Lemma 9 we have that uses space. From Lemma 13 we have that for every , uses space. Since , we have that , as required. We now turn to prove that the stretch of hADO for distances in is .
Lemma 17.
If then
Proof.
We divide the proof into two cases. The case that and the case that . Consider the case that from the correctness of the query of we have that , as required. Consider now the case that . From Lemma 7 it follows that .
Next, we show by induction that for every , either or that as required. Assume that , we show that either either or that . We divide the proof into two cases. The case that and the case that . Consider the case that . From Lemma 13 we have that . From the induction assumption we know that , thus we get that , as required. Consider now the case that . From Lemma 7 it follows that , as required.
The size of is . Therefore, to bound we analyze the series .
Claim 17.1.
If for , then for every .
Proof.
We prove the claim by induction. For , we have that
as required.
Next, we assume that the claim holds for and prove it for . Thus, .
From the recursive definition of we have that .
Thus, we get that:
as required. Next, we move to bound and in the following property, by applying in Λ17.1.
Property 17.
and
Proof.
By applying in Λ17.1 we get that
as required. Since , we get that , as required. In the next theorem, we summarize the properties of the hierarchical distance oracle presented in this section.
Theorem 18.
Let be a parameter, let and let . Let be a random set with vertices. There is an algorithm that constructs in -time a distance oracle with space, such that for every such that it returns in -time.
Theorem 18 follows from Lemma 15, Lemma 16, Lemma 17, and Section 4.3.
Throughout the paper, we refer to the hierarchical distance oracle of Theorem 18 as .
5 Faster constructions for weighted graphs
In this section, we present our main results, faster constructions for the classic -stretch distance oracle with space. In Section 5.1 we present our simplest construction, a subquadratic time construction algorithm for graphs with for every and .
Next, in Section 5.2 and Section 5.3, we present two construction algorithms with a running time of the form . The first algorithm is faster for and the second for .
5.1 Truly subquadratic construction time for every
In this section, we present the first truly subquadratic construction time for every . Specifically, we prove:
Reminder of TheoremΒ 1. Let be a weighted undirected graph and be an integer. There is an time algorithm that constructs a -stretch distance oracle that uses -space and answers distance queries in time.
The distance oracle is constructed as follows. Let be a parameter to be determined later, where . We start by constructing and obtain the set . We then construct . We return the two constructed distance oracles. The query algorithm returns .
Next, we analyze the construction time and the space usage of the distance oracle.
Lemma 19.
The distance oracle is constructed in -time and uses -space.
Proof.
From Theorem 18 it follows that constructing takes time. From Property Section 4.3 it follows that . From Lemma 13 it follows that constructing takes time.
Thus, the total construction time is . To minimize the construction time, we choose such that . From 999https://www.wolframalpha.com/input?i=1%2Bx%2B1%2Fk+%3D+a%2B%281-%28k-1%29x%2F%28k-2%29%2B1%2F%28k%28k-2%29%29%29%2F%28k-1%29, , we get that for the terms are equal. hADO requires that , thus we let .
Increasing increases while decreasing , therefore we get that , and thus the construction time is:
as required.
From Theorem 18 and the fact that it follows that uses space. From Lemma 13 it follows that uses space. Since , we have that , as required. Next, we prove that the stretch is .
Lemma 20.
Proof.
We divide the proof into two cases. The case that and the case that . Consider the case that . From Theorem 18 we have that , as required.
5.2 construction time
In this section, we present a faster construction algorithm for , which improves upon the results of [34]. We prove:
Reminder of TheoremΒ 2. Let be a weighted undirected graph and let be an integer. There is an time algorithm that constructs a -stretch distance oracle that uses -space and answers distance queries in time.
First, we describe the construction of the distance oracle. Similarly to the construction of Section 5.1, let be a parameter to be determined later. We start by constructing , and save the returned set .
Let . Using Lemma 8 we create a -stretch spanner . For every , we add the edge to with weight . For every we compute and store the value of . The construction algorithm is presented in Algorithm 3.
Given , the query algorithm returns . Next, in the following two lemmas, we analyze the construction time and the space usage of the distance oracle.
Lemma 21.
The distance oracle is constructed in -time.
Proof.
From Theorem 18, constructing takes time. From Lemma 8 constructing takes time. Computing for every takes . From Property 4.3 we have that and since we get that time. Thus, the total runtime is , as required.
Lemma 22.
If then the distance oracle uses -space.
Proof.
From Theorem 18 saving takes space. Saving for every takes . From Property 4.3 we know that . Since it follows that . Since we have that , as required. Next, we show that the stretch of the distance oracle is .
Lemma 23.
Proof.
Let be the shortest path between and . We divide the proof into two cases. Consider the case that . From Theorem 18 we know that , as required. Consider now the case that . From Lemma 7 it follows that . From the triangle inequality, it follows that . Since is a -spanner we get that . Thus, . Since and we get that .
Since , we get that . Since we get that , as required.
Next, we move to choose the value of that minimizes the construction time of our distance oracle. From Lemma 21 we know that the construction time is . To minimize the running time we want to have that . From 101010https://www.wolframalpha.com/input?i=y%3D%5Cfrac%7Bk-1%7D%7Bk-2%7Dx-%5Cfrac%7B1%7D%7Bk%28k-2%29%7D%2C+1%2Bx%2B1%2Fk%3D2%2B1%2F%28k-2%29-y,where$x=x_0$and$y=x_t$ , we get that for , the terms are equal. We get a construction time of
5.3 construction time
In this section, we present a faster construction algorithm for , which improves upon the results of [34]. We prove:
Reminder of TheoremΒ 3. Let be a weighted undirected graph and be an integer. There is an time algorithm that constructs a -stretch distance oracle that uses -space and answers distance queries in time.
First, we describe the construction of the distance oracle. Similarly to the construction in Section 5.1, let be a parameter to be determined later. We start by constructing , and save the returned set . Let and be two integer parameters to be determined later. Using Lemma 8 we create a -stretch spanner , which we augment with an edge of weight , for every . We construct . The construction algorithm is presented in Algorithm 4.
Given , the query algorithm returns:
Next, in the following two lemmas, we analyze the construction time and the space usage of the distance oracle.
Lemma 24.
The distance oracle is constructed in -time.
Proof.
From Theorem 18, we know that constructing takes time. From Lemma 8, constructing takes time. From Lemma 14, constructing takes . From Property 4.3 we have that . Thus, constructing takes time.
Lemma 25.
If then the distance oracle uses space.
Proof.
From Theorem 18 it follows that uses space and from Lemma 14 it follows that uses space. From Property 4.3 we know that . Thus, uses space. Since we get that saving takes , as required.
Next, we show that the stretch of the distance oracle is .
Lemma 26.
If then
Proof.
Let be the shortest path between and . We divide the proof into two cases. Consider the case that . From Theorem 18 we know that , as required.
Consider now the case that . From Lemma 7 it follows that . From Lemma 14 we know that . From the triangle inequality, and since is a -spanner it follows that . Where the last inequality holds since .
Since and we get that . Since we get that , as required. Next, we move to choose the value of the parameters that minimizes the running time of our algorithm while maintaining the correctness of the query.
From Lemma 24 we have that the construction time is . In addition, for the correctness, Lemma 26 requires that . To minimize the term regarding and we want to have that . Thus, to find the optimal values for we need to solve the following equations:
From 111111https://www.wolframalpha.com/input?i=y%3D%5Cfrac%7Bk-1%7D%7Bk-2%7Dx-%5Cfrac%7B1%7D%7Bk%28k-2%29%7D%2C+1%2Bx%2B1%2Fk%3D1%2B1%2Fz%2B%281-y%29%2Fw%2C+2%2B%282w-1%29%282z%2B1%29+%3D+2k-1%2C+1%2Fz%3D%281-y%29%2Fw, where , we get that for
, and the equations are satisfied.121212Since and are integers, we need to consider the rounding up of these values; this does not change the asymptotical runtime guarantee. Thus, we get a construction time of:
References
- [1] Amir Abboud and Greg Bodwin. The 4/3 additive spanner exponent is tight. J. ACM, 64(4):28:1β28:20, 2017. doi:10.1145/3088511.
- [2] Amir Abboud, Greg Bodwin, and Seth Pettie. A hierarchy of lower bounds for sublinear additive spanners. SIAM J. Comput., 47(6):2203β2236, 2018. doi:10.1137/16M1105815.
- [3] 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. doi:10.1145/3564246.3585240.
- [4] 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. doi:10.1145/3519935.3520066.
- [5] 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, Wroclaw, Poland, September 8-10, 2014. Proceedings, volume 8737 of Lecture Notes in Computer Science, pages 49β60. Springer, 2014. doi:10.1007/978-3-662-44777-2_5.
- [6] Rachit Agarwal, Brighten Godfrey, and Sariel Har-Peled. Faster approximate distance queries and compact routing in sparse graphs. CoRR, abs/1201.2703, 2012. arXiv:1201.2703.
- [7] 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. doi:10.1137/1.9781611973105.38.
- [8] Surender Baswana, Akshay Gaur, Sandeep Sen, and Jayant Upadhyay. Distance oracles for unweighted graphs: Breaking the quadratic barrier with constant additive error. In Luca Aceto, Ivan DamgΓ₯rd, Leslie Ann Goldberg, MagnΓΊs M. HalldΓ³rsson, Anna IngΓ³lfsdΓ³ttir, and Igor Walukiewicz, editors, Automata, Languages and Programming, 35th International Colloquium, ICALP 2008, Reykjavik, Iceland, July 7-11, 2008, Proceedings, Part I: Tack A: Algorithms, Automata, Complexity, and Games, volume 5125 of Lecture Notes in Computer Science, pages 609β621. Springer, 2008. doi:10.1007/978-3-540-70575-8_50.
- [9] Surender Baswana and Telikepalli Kavitha. Faster algorithms for all-pairs approximate shortest paths in undirected graphs. SIAM J. Comput., 39(7):2865β2896, 2010. doi:10.1137/080737174.
- [10] Surender Baswana, Telikepalli Kavitha, Kurt Mehlhorn, and Seth Pettie. Additive spanners and (alpha, beta)-spanners. ACM Trans. Algorithms, 7(1):5:1β5:26, 2010. doi:10.1145/1868237.1868242.
- [11] 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. doi:10.1002/RSA.20130.
- [12] Davide BilΓ², Shiri Chechik, Keerti Choudhary, Sarel Cohen, Tobias Friedrich, Simon Krogmann, and Martin Schirneck. Approximate distance sensitivity oracles in subquadratic space. TheoretiCS, 3, 2024. doi:10.46298/THEORETICS.24.15.
- [13] Greg Bodwin and Virginia Vassilevska Williams. Better distance preservers and additive spanners. ACM Trans. Algorithms, 17(4), October 2021. doi:10.1145/3490147.
- [14] Shiri Chechik. New additive spanners. 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 498β512. SIAM, 2013. doi:10.1137/1.9781611973105.36.
- [15] 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. doi:10.1145/2591796.2591801.
- [16] 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. doi:10.1145/2746539.2746562.
- [17] Shiri Chechik, Sarel Cohen, Amos Fiat, and Haim Kaplan. (1 + eps)-approximate f-sensitive distance oracles. In Philip N. Klein, editor, Proceedings of the Twenty-Eighth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2017, Barcelona, Spain, Hotel Porta Fira, January 16-19, pages 1479β1496. SIAM, 2017. doi:10.1137/1.9781611974782.96.
- [18] Shiri Chechik and Tianyi Zhang. Path-reporting distance oracles with logarithmic stretch and linear size. In Karl Bringmann, Martin Grohe, Gabriele Puppis, and Ola Svensson, editors, 51st International Colloquium on Automata, Languages, and Programming, ICALP 2024, July 8-12, 2024, Tallinn, Estonia, volume 297 of LIPIcs, pages 42:1β42:18. Schloss Dagstuhl β Leibniz-Zentrum fΓΌr Informatik, 2024. doi:10.4230/LIPIcs.ICALP.2024.42.
- [19] Edith Cohen and Uri Zwick. All-pairs small-stretch paths. J. Algorithms, 38(2):335β353, 2001. doi:10.1006/JAGM.2000.1117.
- [20] Michael Elkin, Ofer Neiman, and Christian Wulff-Nilsen. Space-efficient path-reporting approximate distance oracles. Theor. Comput. Sci., 651:1β10, 2016. doi:10.1016/J.TCS.2016.07.038.
- [21] Michael Elkin and David Peleg. (1+epsilon, beta)-spanner constructions for general graphs. SIAM J. Comput., 33(3):608β631, 2004. doi:10.1137/S0097539701393384.
- [22] Michael Elkin and Seth Pettie. A linear-size logarithmic stretch path-reporting distance oracle for general graphs. ACM Trans. Algorithms, 12(4):50:1β50:31, 2016. doi:10.1145/2888397.
- [23] Michael Elkin and Idan Shabat. Path-reporting distance oracles with logarithmic stretch and size o(n log log n). In 64th IEEE Annual Symposium on Foundations of Computer Science, FOCS 2023, Santa Cruz, CA, USA, November 6-9, 2023, pages 2278β2311. IEEE, 2023. doi:10.1109/FOCS57990.2023.00141.
- [24] Joachim Gudmundsson, Christos Levcopoulos, Giri Narasimhan, and Michiel H. M. Smid. Approximate distance oracles for geometric graphs. In David Eppstein, editor, Proceedings of the Thirteenth Annual ACM-SIAM Symposium on Discrete Algorithms, January 6-8, 2002, San Francisco, CA, USA, pages 828β837. ACM/SIAM, 2002. URL: http://dl.acm.org/citation.cfm?id=545381.545489.
- [25] 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. doi:10.1145/3564246.3585157.
- [26] Avi Kadria and Liam Roditty. Faster algorithms for -stretch distance oracles. arXiv preprint arXiv:2507.06721, 2025. doi:10.48550/arXiv.2507.06721.
- [27] Tsvi Kopelowitz, Ariel Korin, and Liam Roditty. On the space usage of approximate distance oracles with sub-2 stretch. In Karl Bringmann, Martin Grohe, Gabriele Puppis, and Ola Svensson, editors, 51st International Colloquium on Automata, Languages, and Programming, ICALP 2024, July 8-12, 2024, Tallinn, Estonia, volume 297 of LIPIcs, pages 101:1β101:18. Schloss Dagstuhl β Leibniz-Zentrum fΓΌr Informatik, 2024. doi:10.4230/LIPIcs.ICALP.2024.101.
- [28] Hung Le. Approximate distance oracles for planar graphs with subpolynomial error dependency. In Nikhil Bansal and Viswanath Nagarajan, editors, Proceedings of the 2023 ACM-SIAM Symposium on Discrete Algorithms, SODA 2023, Florence, Italy, January 22-25, 2023, pages 1877β1904. SIAM, 2023. doi:10.1137/1.9781611977554.CH72.
- [29] Manor Mendel and Assaf Naor. Ramsey partitions and proximity data structures. In 47th Annual IEEE Symposium on Foundations of Computer Science (FOCS 2006), 21-24 October 2006, Berkeley, California, USA, Proceedings, pages 109β118. IEEE Computer Society, 2006. doi:10.1109/FOCS.2006.65.
- [30] Merav Parter. Bypassing erdΕsβ girth conjecture: Hybrid stretch and sourcewise spanners. In Javier Esparza, Pierre Fraigniaud, Thore Husfeldt, and Elias Koutsoupias, editors, Automata, Languages, and Programming - 41st International Colloquium, ICALP 2014, Copenhagen, Denmark, July 8-11, 2014, Proceedings, Part II, volume 8573 of Lecture Notes in Computer Science, pages 608β619. Springer, 2014. doi:10.1007/978-3-662-43951-7_49.
- [31] 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. doi:10.1007/11523468_22.
- [32] Mikkel Thorup and Uri Zwick. Approximate distance oracles. J. ACM, 52(1):1β24, 2005. doi:10.1145/1044731.1044732.
- [33] 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. URL: http://dl.acm.org/citation.cfm?id=1109557.1109645.
- [34] 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. doi:10.1137/1.9781611973099.18.
- [35] Christian Wulff-Nilsen. Approximate distance oracles for planar graphs with improved query time-space tradeoff. In Robert Krauthgamer, editor, Proceedings of the Twenty-Seventh Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2016, Arlington, VA, USA, January 10-12, 2016, pages 351β362. SIAM, 2016. doi:10.1137/1.9781611974331.CH26.
Appendix A Comparison with previous results
Comparison for weighted graphs
| Construction time | Reference | Comments |
| [32] | ||
| Theorem 1 | ||
| [9] | ||
| [34] | ||
| Theorem 2 | ||
| [34] | ||
| Theorem 3 |
| [9, 34] | ||||||||||
| Theorem 2 |
