Siddharth Gupta

Adrian Kosowski

Laurent Viennot

Exploiting Hopsets: Improved Distance Oracles for Graphs of Constant Highway Dimension and Beyond

Keywords: Hopsets, Distance Oracles, Graph Algorithms, Data Structures

For fixed h ≥ 2, we consider the task of adding to a graph G a set of weighted shortcut edges on the same vertex set, such that the length of a shortest h-hop path between any pair of vertices in the augmented graph is exactly the same as the original distance between these vertices in G. A set of shortcut edges with this property is called an exact h-hopset and may be applied in processing distance queries on graph G. In particular, a 2-hopset directly corresponds to a distributed distance oracle known as a hub labeling. In this work, we explore centralized distance oracles based on 3hopsets and display their advantages in several practical scenarios. In particular, for graphs of constant highway dimension, and more generally for graphs of constant skeleton dimension, we show that 3-hopsets require exponentially fewer shortcuts per node than any previously described distance oracle, and also offer a speedup in query time when compared to simple oracles based on a direct application of 2-hopsets. Finally, we consider the problem of computing minimum-size h-hopset (for any h ≥ 2) for a given graph G, showing a polylogarithmic-factor approximation for the case of unique shortest path graphs. When h = 3, for a given bound on the space used by the distance oracle, we provide a construction of hopset achieving polylog approximation both for space and query time compared to the optimal 3-hopset oracle given the space bound.

Introduction

An exact h-hopset for a weighted graph G is a weighted edge set, whose addition to the graph guarantees that every pair of vertices has a path between them with at most h edges (hops) and whose length is exactly the length of shortest path between the vertices.

The concept of a hopset was first explicitly described by Cohen [START_REF] Cohen | Polylog-time and near-linear work approximation scheme for undirected shortest paths[END_REF] in its approximate setting, in which the length of h-hop path between a pair of vertices in the hopset should approximate the length of the shortest path in G. Hopsets were introduced in the context of parallel computation of approximate shortest paths. In this paper, we study hopsets in their exact version, with the general objective of optimizing exact shortest path queries.

Data structures which allow for querying distance between any pair of vertices of a graph have been intensively studied under the name of distance oracles. The efficiency of an exact distance oracle is typically measured by the interplay between the space requirement of the representation of the data structure and its decoding time. It is a well-established empirical fact that many real-world networks admit efficient (i.e., low-space and fast) distance oracles [START_REF] Akiba | Dynamic and historical shortest-path distance queries on large evolving networks by pruned landmark labeling[END_REF][START_REF] Delling | Robust distance queries on massive networks[END_REF]. A key example here concerns transportation networks, and specifically road networks, which are empirically known [START_REF] Gutman | Reach-based routing: A new approach to shortest path algorithms optimized for road networks[END_REF][START_REF] Goldberg | Reach for A*: Efficient point-to-point shortest path algorithms[END_REF][START_REF] Abraham | Highway dimension, shortest paths, and provably efficient algorithms[END_REF] to be augmentable by carefully tailored sets of shortcut edges, allowing for shortest-path computation. These sets of shortcuts may [START_REF] Cohen | Polylog-time and near-linear work approximation scheme for undirected shortest paths[END_REF][START_REF] Gavoille | Distance labeling in graphs[END_REF][START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF]) and 3-hopsets (this paper). Size represents the number of shortcut edges in the hopset, i.e., the number of O(log n)bitsize words when measuring oracle size. The main results concern skeleton dimension and are stated in simplified form, assuming average edge length at most O(poly log n), with expected query times given for both types of oracles.

be hopsets (as is the case for the hub-labeling approach which effectively implements a 2-hopset), but may also be considered in some related (and frequently more involved) framework, such as contraction hierarchies [START_REF] Geisberger | Contraction hierarchies: Faster and simpler hierarchical routing in road networks[END_REF] or transit-node routing [START_REF] Bast | Ultrafast shortest-path queries via transit nodes[END_REF].

An interesting theoretical insight due to Abraham et al. [START_REF] Abraham | Highway dimension and provably efficient shortest path algorithms[END_REF][START_REF] Abraham | Highway dimension and provably efficient shortest path algorithms[END_REF][START_REF] Abraham | Highway dimension, shortest paths, and provably efficient algorithms[END_REF] provides theoretical bounds on the number of shortcuts required in all of the above-mentioned frameworks. They introduce a parameter describing the structure of shortest paths within ball neighborhoods of a graph, called highway dimension h. They also express the number of shortcuts that need to be added for each node so as to achieve shortest-path queries in a graph of n nodes with weighted diameter D as a polynomial of h, log n, and log D; this approach has been extended in subsequent work [START_REF] Abraham | VCdimension and shortest path algorithms[END_REF][START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF]. The value of h is known to be small in practice (e.g., typically h < 100 for continental-sized road networks [START_REF] Abraham | Highway dimension and provably efficient shortest path algorithms[END_REF]), and does indeed appear to be inherently linked to the size of the required shortcut sets. In fact, empirical tests have suggested that the (average) number of necessary shortcuts per node is in fact very close to h, laying open the question of whether the additional dependence of the number of shortcuts on logarithmic factors in n and D may be an artifact of the theoretical analysis of the oracles, which for each node require a separate shortcut for every "scale" of distance.

Results and Organization of the Paper

Our main result is to provide strong evidence that the dependence of the number of shortcuts on such logarithmic factors in n and D is indeed not essential, and we design a simple distance oracle based on a 3-hopset in which the number of shortcuts per node depends only on h, log log n, and the logarithm of the average edge length. This result is in fact shown in the framework of a strictly broader class of graphs, namely, graphs with a bounded value of a parameter known as skeleton dimension k (k ≤ h), describing the width of the shortest-path tree of a node after pruning all branches at a constant fraction α of their depth. Considering various ranges of fraction α for increasing distance ranges was a novel key step for improving over [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF][START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF] from a 2-hopset construction to a 3-hopset construction.

From a general perspective, our connection between h-hopsets and distance oracles is original and offers new perspectives for studying the trade-off between size and query time of distance oracles. To exemplify this, we provide a construction of h-hopsets for graphs of treewidth t following a classical approach in pre-processing product queries on trees [START_REF] Alon | Optimal preprocessing for answering on-line product queries[END_REF][START_REF] Chazelle | Computing on a free tree via complexity-preserving mappings[END_REF]. For 3-hopsets, we obtain a distance oracle with quadratic dependency in t which improves over the construction of [START_REF] Chaudhuri | Shortest paths in digraphs of small treewidth. part I: sequential algorithms[END_REF] (which has cubic dependency) for t = ω(log 2 log n). The space and time-bounds of oracles based on 3-hopsets are presented in Table 1, and compared with the corresponding parameters of oracles based on 2-hopsets. For the case of constant skeleton dimension or constant treewidth, we remark that using a 3-hopset instead of a 2-hopset reduces the number of shortcuts per node from O(log n) to O(log log n) while achieving a query time of O(log 2 log n).

A classical assumption (applied, e.g., in almost all literature on transportation networks) resides in the uniqueness of shortest paths. It can be made without loss of generality by slightly perturbing the weights of the edges or by using appropriate tie break rules. In this context of unique shortest path graph (USP) graphs where there is a unique shortest path P uv between any two nodes u and v, we propose an LP-based approximation algorithm for constructing h-hopsets with size within a polylog factor from optimal. Our construction can be seen as a non-trivial generalization of the prehub labeling introduced in [9] from 2 to more hops. In the case h = 3, we further extend our approach to provide an algorithm which constructs distance oracles in USP graphs based on 3-hopsets, with (approximate) optimality guarantees on size and query time. The form of guarantees we obtain is again novel: for a given size bound S of 3-hopset based oracle, we construct an oracle with size larger than S by at most a polylog factor which has average query time within a polylog factor of the performance achieved by the best oracle with size S.

The rest of the paper is organized as follows. In Section 2, we introduce the necessary notions related to h-hopset and give a general approach for how a h-hopset can be used as a distance oracle, focusing on the special case of h = 3. In Section 3, we provide our first main result, using 3-hopsets to obtain improved (smaller and faster) distance oracles in graphs with bounded skeleton dimension. In Section 4, we present our second main result about approximating h-hopsets and constructing 3-hopset based oracles in USP graphs. Finally, Section 5, we show how to construct efficient h-hopsets and 3-hopset based oracles for bounded treewidth graphs.

Our work is presented in the context of weighted undirected graphs, but all results can easily be extended to weighted directed graphs.

Other Related Work

Hopsets. Exact hopsets were implicitly constructed in the context of single-source shortest paths parallel computation [START_REF] Ullman | High-probability parallel transitive closure algorithms[END_REF][START_REF] Klein | A randomized parallel algorithm for single-source shortest paths[END_REF][START_REF] Cohen | Using selective path-doubling for parallel shortest-path computations[END_REF][START_REF] Shi | Time-work tradeoffs of the single-source shortest paths problem[END_REF]. Such works study the work versus time trade-offs of such computation. Cohen [START_REF] Cohen | Polylog-time and near-linear work approximation scheme for undirected shortest paths[END_REF] explicitly introduced the notion of (h, ǫ)-hopset of G as set H of weighted edges such that paths of at most h hops in G ∪ H have length within (1 + ǫ) of the corresponding shortest path in G. The parameter h is called the hopbound. For any graph G and ǫ, ǫ ′ > 0, she proposed a construction of (O(poly log n), ǫ)-hopset of G with size O(n 1+ǫ ′ ). More recently, Elkin et al. [START_REF] Elkin | Hopsets with constant hopbound, and applications to approximate shortest paths[END_REF] proposed the construction of (O(ǫ -1 log κ) log κ , ǫ)-hopset with O(n 1+1/κ log n log κ) edges for any ǫ > 0 and integral κ ≥ 1. Abboud et al. [START_REF] Abboud | A hierarchy of lower bounds for sublinear additive spanners[END_REF] recently showed the optimality of the Elkin et al. [START_REF] Elkin | Hopsets with constant hopbound, and applications to approximate shortest paths[END_REF] result. In particular, they showed that for any δ > 0 and integer k, any hopset of size less than n

1+ 1 2 k+1 -1 -δ must have hop bound h = Ω(c k /ǫ k+1 )
, where c k is a constant depending only on k. The linear size case was then improved in [START_REF] Elkin | Linear-size hopsets with small hopbound, and distributed routing with low memory[END_REF]. As far as we know, exact hopsets (with ǫ = 0) have not been explicitly studied. However, they are related to the following well studied notion.

Hopsets vs. TC-spanners. In directed graphs, a hopset can be seen as a special case of an htransitive-closure spanner (h-TC-spanner). Hopsets and TC-spanners are fundamental graph-theoretic objects and are widely used in various settings from distance oracles to pre-processing for range queries in sequential or parallel setting or even in property testing. The concept of adding transitive arcs to a digraph in order to reduce its diameter was introduced by Thorup [START_REF] Thorup | Shortcutting planar digraphs[END_REF] in the context of parallel processing. Bhattacharyya et al. [START_REF] Bhattacharyya | Transitive-closure spanners[END_REF] defined an h-TC-spanner of an unweighted digraph G as a digraph H with same transitive closure as G and diameter at most h. They note that this is a central concept in a long line of work around pre-processing a tree for range queries [START_REF] Alon | Optimal preprocessing for answering on-line product queries[END_REF][START_REF] Chazelle | Computing on a free tree via complexity-preserving mappings[END_REF][START_REF] Thorup | Parallel shortcutting of rooted trees[END_REF]. A TC-spanner can also be defined as a spanner (for the classical spanner definition [START_REF] Peleg | Graph spanners[END_REF]) of the transitive closure of a graph that has bounded diameter. We will see that an exact h-hopset defines a h-TC-spanner but that the converse is not necessarily true. Bhattacharyya et al. [START_REF] Bhattacharyya | Transitive-closure spanners[END_REF] proposed a construction of h-TC-spanner of size O(n log nλ h (n)) for H-minor-free graphs (where λ h denotes the hth-row inverse Ackermann function, cf. Section 5).

Exact Distance Oracles. A long line of research studies the interplay between data structure space and query decoding time. A lot of attention has been given to distance oracles for planar graphs [START_REF] Djidjev | On-line algorithms for shortest path problems on planar digraphs[END_REF][START_REF] Rao Arikati | Planar spanners and approximate shortest path queries among obstacles in the plane[END_REF][START_REF] Chen | Shortest path queries in planar graphs[END_REF][START_REF] Cabello | Many distances in planar graphs[END_REF][START_REF] Fakcharoenphol | Planar graphs, negative weight edges, shortest paths, and near linear time[END_REF][START_REF] Cohen-Addad | Fast and compact exact distance oracle for planar graphs[END_REF][START_REF] Gawrychowski | Better tradeoffs for exact distance oracles in planar graphs[END_REF], and it has recently been shown that a distance oracle with O(n 1.5 ) space and O(log n) query-time is possible [START_REF] Gawrychowski | Better tradeoffs for exact distance oracles in planar graphs[END_REF]. In the context of weighted directed graphs with treewidth t, Chaudhuri and Zaroliagis [START_REF] Chaudhuri | Shortest paths in digraphs of small treewidth. part I: sequential algorithms[END_REF] propose a distance oracle using O(t 2 nλ h (n)) space and O(t 3 h + λ h (n)) query time for integral h > 1 where λ h is the hth-row inverse Ackermann function (as defined in Subsection 5). In the context of unweighted graphs with treewidth t, Farzan and Kamali [START_REF] Farzan | Compact navigation and distance oracles for graphs with small treewidth[END_REF] obtain distance oracles with O(t 3 log 3 t) query time using optimal space (within low order terms). This construction heavily relies on the unweighted setting as exhaustive look-up tables are constructed for handling graphs with polylogarithmic size.

Distance Labelings and 2-Hopsets. The distance labeling problem is a special case of a distributed distance oracle, and consists of assigning labels to the nodes of a graph such that the distance between two nodes s and t can be computed from the labels of s and t (see, e.g., [START_REF] Gavoille | Distance labeling in graphs[END_REF]).

The notion of 2-hopset studied in this work coincides with the special case of two-hop distance labeling (also called hub-labeling), where labels are constructed from hub sets: in hub-labeling, a small hub set S(u) ⊆ V (G) is assigned to each node of a graph G such that for any pair u, v of nodes, the intersection of hub sets S(u) ∩ S(v) contains a node on a shortest uv path. Such a construction is formally proposed in [START_REF] Cohen | Reachability and distance queries via 2-hop labels[END_REF] and is implicitly introduced by Gavoille et al. [START_REF] Gavoille | Distance labeling in graphs[END_REF] and applied to graphs of treewidth t with labels of O(t log n) size and allows to answer distance queries in O(t log n) time; the hub sets have a hierarchical structure, which allows for an improvement of query time to O(t log log n) time by a binary search over levels. Hub labelings are the currently best known distance labelings for sparse graphs, achieving sublinear node label size [START_REF] Alstrup | Sublinear distance labeling[END_REF][START_REF] Gawrychowski | Sublinear-space distance labeling using hubs[END_REF], and may also be used to provide a 2-additive-approximation for distance labeling in general graphs using sublinear-space labels [START_REF] Gawrychowski | Sublinear-space distance labeling using hubs[END_REF].

In graphs of bounded highway dimension, hub labels were among the first identified distance oracles to provide label size and query time polynomial in the highway dimension and polylogarithmic in other graph parameters [START_REF] Abraham | Highway dimension, shortest paths, and provably efficient algorithms[END_REF]. This result was then extended to the more general class of graphs with bounded skeleton dimension [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF][START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF].

Hub sets with near to optimal size can be constructed in polynomial time. A greedy set cover-type O(log n)-approximation algorithm (with respect to average size of a hub set) was proposed by Cohen et al. [START_REF] Cohen | Reachability and distance queries via 2-hop labels[END_REF]. For the case of USP graphs, this approximation ratio was improved by Angelidakis et al. [START_REF] Angelidakis | Algorithmic and hardness results for the hub labeling problem[END_REF] to the logarithm of the graph hop-diameter D H , i.e., the maximum number of hops of a shortest path in G, showing an approximation gap between USP and non-USP graphs.

Preliminaries

Definitions

We are given a weighted undirected graph G = (V, E, ω) where ω : E → R + associates a weight with each edge of G. For a positive integer parameter h and a pair u, v ∈ V , the h-limited distance between u and v, denoted d h G (u, v), is defined as the length of the shortest path from u to v that contains at most h edges (aka hops). The usual shortest path distance can be defined as

d G (u, v) = d n-1 G (u, v).
For the sake of brevity, we often let uv denote the pair {u, v} representing an edge from u to v.

Definition 1 An (exact) h-hopset for a weighted graph G is a set of edges H such that d h G∪H (u, v) = d G (u, v) for all u, v in V (G) where G∪H = (V, E ∪H, w ′ ) is the graph augmented with edges of the hopset with weights w ′ (u, v) = d G (u, v) for uv ∈ H and w ′ (u, v) = w(u, v) for uv ∈ E \ H. The parameter h is called the hopbound of the hopset. Edges from set H are called shortcuts in G.

By convention, we will assume that all self-loops at nodes of V are included in H. Thus, G ∪ H is a graph whose h-th power in the (min, +) algebra on n × n matrices of edge weights corresponds to the transitive closure of the weight matrix of graph G.

Equivalently, a h-hopset can be defined as a set H of edges such that for any pair s, t, there exists a path P of at most h edges from s to t in G ∪ H and a shortest path Q from s to t in G such that all nodes of P belong to Q and appear in the same order. Note that a h-hopset is completely specified by its set H of edges as the associated weights are deduced from distances in the graph.

Using a Hopset as a Distance Oracle

Hopsets may be used to answer shortest-path queries in a graph G = (V, E). In general, given a hopset H, the naïve way to approach a query for d G (u, v) for a given node pair u, v is to perform a bidirectional Dijkstra search in graph G ∪ H from this node pair, limited to a maximum of ⌈h/2⌉ hops distance from each of these nodes. We have, in particular for any pair u, v ∈ V :

d G (u, v) = min w∈V (d ⌈h/2⌉ G∪H (u, w) + d ⌊h/2⌋ G∪H (v, w)).

Different optimizations of this technique are possible.

In this paper, we focus only on the time complexity of the case of h = 3, where we perform the following optimization of query execution. We represent set H as the union of two (not necessarily disjoint) sets of shortcuts, H = H 1 ∪ H 2 , where an edge belongs to H 1 if it is used as the first or third (last) hop on a shortest path in G ∪ H, and it belongs to G ∪ H 2 if it is used as the second hop on such a path. By convention, we assume that self-loops at nodes are added to H 1 , thus e.g. a 3-hop path between a pair of adjacent nodes in G is constructed by taking a self-loop from H 1 , the correct edge from G ⊆ G ∪ H 2 , and another self-loop from H 1 . (Note that we never directly use edges of G as first or last hops in the hopset; if such an edge is required for correctness of construction, it should be explicitly added to set H 1 .) We further apply an orientation to the shortcuts in H 1 , constructing a corresponding set of arcs H 1 , such that, for any node pair u, v ∈ V , there exist x, y ∈ V such that (u, x) ∈ H 1 , {x, y} ∈ H 2 , (v, y) ∈ H 1 , and:

d G (u, v) = d G (u, x) + d G (x, y) + d G (y, v).
The orientation (w, z) of an arc in H 1 indicates that edge {w, z} can be used as the first edge of a 3-hop path from w or as the third edge of a 3-hop path to w. We note that

|H 1 | ≤ | H 1 | ≤ 2|H 1 |, since each shortcut from H 1 corresponds to at most a pair of symmetric arcs in H 1 . For a node w ∈ V , let N 1 (w) = |{x ∈ V : (w, x) ∈ H 1 }| represent the out-neighborhood of w in the graph (V, H 1 ).
To perform shortest path queries on G, for each node w, we now store the list {(x, d G (w, x)) : x ∈ N 1 (w)}. We also store a hash map, mapping all node pairs {x, y} ∈ H 2 to the length of the respective link, d G (x, y). Now, we answer the distance query for a node pair u, v ∈ G as follows:

d G (u, v) = min x∈N1(u),y∈N1(v):{x,y}∈H2 (d G (u, x) + d G (x, y) + d G (y, v)).
Using the given data structures, the query is then processed using

|N 1 (u)| • |N 1 (v)| hashmap look-ups, one for each pair (x, y) ∈ N 1 (u) × N 1 (v), i.e., in time T uv = O(|N 1 (u)| • |N 1 (v)|)
. Time T uv is simply referred to as the query time for the considered node pair in the 3-hopset oracle H. Assuming uniform query density over all node pairs, the uniform-average query time T (H) is given as:

T (H) ≡ E uv T uv = O 1 n 2 u∈V |N 1 (u)| 2 = O(|H 1 | 2 /n 2 )
. Thus, in the uniform density setting (which we refer to only in Section 4), the average time of processing a query is proportional to the square of the average degree of a node with respect to edge set H 1 .

The size of set H 2 affects only the size of the data structure required by the distance oracle, which is given as at most S = O(|E| + |H 1 | + |H 2 |) edges, with each edge represented using O(log n) bits.

In the 3-hopset distance oracles described in the following sections, we will confine ourselves to describing shortcut sets H 1 and H 2 , noting that the correct orientation H 1 of H 1 will follow naturally from the details of the provided constructions.

Bounded Skeleton Dimension

A formal definition of the notion of skeleton dimension relies on the concept of the geometric realization of a graph, cf. [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF]. The geometric realization G of G can be seen as the "continuous" graph where each edge is seen as infinitely many vertices of degree two with infinitely small edges, such that for any uv ∈ E(G) and t ∈ [0, 1], there is a node in G at distance td G (u, v) from u on edge uv. Given a shortest-path tree T u of node u with length function ℓ : E(T u ) → R + , obtained as the union of shortest paths {P uv : v ∈ V (G)}, we treat it as directed from root to leaves and consider the geometric realization T u of this directed graph. We define the reach of v ∈ V ( T u ) as the distance from v to the furthest leaf in its subtree of the directed tree T u , i.e., Reach Tu (v) := max x:v∈Pux d Tu (v, x). For a given value α > 0, we then define the skeleton T * u of T u as the subtree of T u induced by nodes with reach at least α times their distance from the root. More precisely, T * u is the subtree of

T u induced by {v ∈ V ( T u ) | Reach Tu (v) ≥ αd Tu (u, v)}.
The α-skeleton dimension k α of a graph G is now defined as the maximum width of the skeleton of a shortest path tree, taken over cuts at all possible distances from the root of the tree:

k = max u∈V (G) max r>0 | Cut r ( T * u )|, where Cut r ( T * u ) is the set of nodes v ∈ V ( T * u ) with d T * u (u, v) = r. When α = 1 2 , k 1/2 is simply called the skeleton dimension of G and we let k = k 1/2 denote it.
The definition was originally proposed with α = 1 2 (for comparison with highway dimension) in the context of USP graphs [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF]. In the long version [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF], the definition is extended to other choices of α with 0 < α < 1 and applies to any choice of shortest paths trees that pairwise agree on their paths (the path from u to v in T u must be the reverse of the path from v to u in T v ). In the non-USP case, the skeleton dimension should be measured with the best choice of agreeing trees. In particular, if a small perturbation of the edge weights of G provides unique shortest path trees whose skeletons have width at most k α , then the skeleton dimension of G is at most k α . The α-skeleton dimension (with parameter α) was introduced in [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF] for the sake of a general definition with fixed α value in mind. We use it here in a novel manner with α tending towards 0 as we consider larger distances, enabling analysis of our new construction.

For the definition of the related concept of highway dimension, we refer the readers to [START_REF] Abraham | Highway dimension and provably efficient shortest path algorithms[END_REF]. We note that if a graph G has highway dimension h, then G has skeleton dimension k = k 1/2 ≤ h; hence, in all subsequent asymptotic analyses, upper bounds expressed in terms of skeleton dimension can be replaced by analogous bounds in terms of highway dimension.

Construction of the 3-Hopset

We denote by L max the maximum length of an edge in graph G. The construction of the 3-hopset H is obtained by taking a union of sets of shortcuts, each of which covers sets of node pairs within a given distance range. The first shortcut set H ′ covers all node pairs u, v ∈ V with d G (u, v) ≤ D ′ , for some choice of distance bound D ′ , whereas each of the subsequent shortcut sets H (D) covers nodes at a distance in an exponentially increasing distance range, d G (u, v) ∈ [D, D 1+ǫ ], where ǫ := 1 2 log 2 k is suitably chosen. We then put:

H = H ′ ∪ i=1,2,... H (D ′ i(1+ǫ) ) .
Construction of set H ′ . We note that a construction of 2-hopsets for graphs of skeleton dimension k was performed in [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF]. As a direct corollary of [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF][Lem. 2, Cor. 1,2], given a distance bound D ′ , there exists a randomized polynomial-time construction of a set of shortcuts H ′ for graph G with the property that for any pair of nodes u, v

∈ V with d G (u, v) ≤ D ′ , we have d 2 G∪H ′ = d G (u, v), such that |H ′ | = O(nk log D ′ ),
|H ′ | = O(nk(log log n + log L max + log k)),
and for all u ∈ V :

E deg H ′ (u) = O(k(log log n + log L max + log k)), deg H ′ (u) = O(k log log n(log log n + log L max + log k) + log n).
We remark that, without loss of generality, in asymptotic analysis one may assume that L max ≤ kL, where L is the average edge length in G, noting that edges longer than kL can be subdivided into edges of length at most kL by inserting additional vertices, increasing the number of nodes of the graph only by a multiplicative constant. Thus, in the above bounds, we can replace (log log n + log L max + log k) by (log log n + log L + log k).

Construction of set H (D) . We now proceed to construct a 3-hopset for node pairs u, v with d G (u, v) ∈ [D, D 1+ǫ ]. The construction of set H (D) is randomized and completely determined by assignment of real values ρ(u) ∈ [0, 1] to each node u ∈ V , uniformly and independently at random. We condition all subsequent considerations on the event that all values ρ are distinct, i.e., |ρ(V

)| = |V |, which holds with probability 1. ( ρ(V ) = {ρ(v)|v ∈ V } ) Now, hopset H (D) is defined as H (D) := H (D) 1 ∪ H (D)
2 , where following our usual notation, H We now put:

H (D) 1 := {ur : u ∈ V, r ∈ R(u)}.
Set of middle hops. We put in

H (D) 2
links between all pairs of nodes which have a small value of ρ, satisfy the natural upper bound of D 1+ǫ on distance between them, and have sufficiently large reach, i.e., the shortest path between them can be extended by at least D/4:

H (D) 2 := qr : q, r ∈ u∈V R (D) (u) ∧ dG(q, r) ≤ D 1+ǫ -D/2 ∧ (∃v∈V r ∈ Pqv ∧ dG(r, v) ≥ D/4) .
The validity of H as a 3-hopset is immediate to verify from the construction: consider u, v and i ≥ 0

such that d G (u, v) ∈ [D, D 1+ǫ ] with D = D ′i(1+ǫ) .
For q = argmin w∈Puv,dG(u,w)∈[D/4,D/2] ρ(w) and r = argmin w∈Puv ,dG(u,w)∈[D/2,3D/4] ρ(w), we then

have uq ∈ H (D) 1 , qr ∈ H (D) 2
and vr ∈ H

(D)
1 , yielding a 3-hop shortest path from u to v. For d G (u, v) ≤ D ′ , H ′ contains a 2-hop shortest path from u to v.

Bound on 3-Hopset Size and Oracle Time

Lemma 1 Fix u ∈ V and D > 0. We have:

|R (D) (u)| ≤ k.
Proof. By the fact that the size of the cut of the skeleton tree for node u at distance D/2 from u is upperbounded by the skeleton dimension k, we have that the set of paths

P := {Π v : v ∈ V ∧ d G (u, v) ≥ D}, where Π v := {w ∈ P uv : d G (u, w) ∈ [D/
deg H 1 (u) ≤ deg H ′ (u) + k • O(log log(nLmax) log k) = O(k log log n log k(log log n + log L) + log n), (1)
E deg H 1 (u) ≤ E deg H ′ (u) + k • O(log log(nLmax) log k) = O(k log k(log log n + log L)), (2)
|H1| ≤ |H ′ | + nk • O(log log(nLmax) log k) = O(nk log k(log log n + log L)). (3)
We now proceed to bound the size of the set H 2 of middle hopsets. We now proceed under the assumption that the event from the claim of the Lemma holds. We now consider an arbitrary node q ∈ R (D) (u) for some u ∈ V , and look at deg H (D) 2 (q). We now have that if qr ∈ H and the above Lemma, the following conditions jointly hold:

• ρ(r) ≤ L max /D • r ∈ {w ∈ V : ∃ v∈V D 1+ǫ ≥ d G (q, v) ≥ d G (q, w) + D/4 ∧ P qw ⊆ P gv } =: W (q).
We note that W (q) is the subset of the vertex set of the shortest path tree of node q, pruned to contain only those paths which have reach at least D/4 at depth less than D 1+ǫ . This tree has depth bounded by D 1+ǫ , and width bounded by an α-skeleton dimension k α (following [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF]), with parameter α = D/4 D 1+ǫ = D -ǫ /4. Following [START_REF] Kosowski | Beyond highway dimension: Small distance labels using tree skeletons[END_REF][Section 6], k α can be easily expressed using skeleton dimension k = k 1/2 as:

k α ≤ k ⌈log 2 (1+1/α)⌉ < k 1+log 2 (4D ǫ ) = k 3 D ǫ log 2 k .
We then have

|W (q)| ≤ D 1+ǫ k α < k 3 D 1+ǫ(1+log 2 k)
. Moreover, by an easy concentration bound, we have that for all q ∈ V , |{r ∈ W (q) : ρ(r) ≤ L max /D}| = O(log n) + 2Lmax D |W (q)|, with probability 1 -O(1/n 2 ). It follows that with probability 1 -O(1/n 2 ), we have for all q ∈ u∈V R (D) (u):

deg H (D) 2 (q) ≤ O(log n) + 2L max D |W (q)| ≤ O(log n + L max k 3 D ǫ log 2 k ).
Noting that with probability 1 -O(1/n 2 ):

| u∈V R (D) (u)| ≤ |{w ∈ V : ρ(w) ≤ L max /D| ≤ O(log n + nL max /D)
we finally obtain that with probability 1 -O(1/n 2 ):

|H (D) 2 | ≤ O(log n + nLmax/D)O(log n + Lmaxk 3 D ǫ log 2 k ) = O(log 2 n + nL 2 max k 3 D ǫ log 2 k-1 ) ≤ O(nL 2 max k 3 D -1/2 ) ≤ O(nD ′-1/4 ) ≤ O(n/ log 3 n),
where in the last two transformations we use the fact that ǫ = 1 2 log 2 k and that D ≥ D ′ ≥ L 4 max k 6 log 12 n. Using a union bound and summing over all levels of the construction, we eventually obtain that with probability 1 -O(1/n):

|H 2 | ≤ O(n/ log 2 n). (4)
Thus, the set of middle links is sparse and does not contribute to the asymptotic size of the overall representation of the 3-hopset. Overall, considering a randomized construction which rejects random choices of ρ for which any of the considered w.h.p. events fail, by combining Eq. ( 1)-( 4) with the hopset-based distance oracle framework described in the Preliminaries, we obtain the following Theorem.

Theorem 1 For a unique shortest path graph with skeleton dimension k and average link length L ≥ 1, there exists a randomized construction of a 3-hopset distance oracle of size |H| = O(nk log k(log log n + log L)), which for an arbitrary queried node pair performs distance queries in expected time O(k 2 log 2 k(log 2 log n+ log 2 L)) (where the expectation is taken over the randomized construction of the oracle), and in time O(k 2 log 2 k log 2 log n(log 2 log n + log 2 L) + log 2 n) with certainty.

In particular, for graphs with constant-length edges and small skeleton dimension (k = O(log n)), the 3-hopset has size |H| = O(nk log k log log n), with expected time of any query given as O(k 2 log 2 k log 2 log n).

LP-based Approximation Algorithm

In this section, we propose an Integer Linear Programming (ILP) formulation for h-hopsets with a minimum number of edges, which we then relax to a LP formulation. Whereas both formulations are applicable to the general case, we prove relations between them only for USP graphs.

ILP and LP Formulations

A necessary and sufficient condition for H to be a h-hopset for G is that for every pair of vertices s, t there exists a path P st = (s = v 0 , v 1 , . . . , v lst = t) in G ∪ H such that l st ≤ h and in graph G there exists some shortest st path passing through all of the vertices v 0 , . . . , v lst , in the given order. For a fixed pair s, t, we consider the directed graph H st with vertex set V × {0, . . . , h} ≡ V h (by convention, elements of V h will be denoted compactly as v i , where v ∈ V , i ∈ {0, . . . , h}) and with an arc set defined as follows. For i ∈ {0, . . . , h -1}, we add arc (u i , v i+1 ) to H st if and only if {u, v} ∈ G ∪ H and u, v lie on some shortest st path in the given order, i.e., if

d G (s, u) + d G (u, v) + d G (v, t) = d G (s, t).
In particular, all arcs of the form (u i , u i+1 ), for u ∈ V on a st shortest path, belong to H st . Now, we have that H is a h-hopset for G if and only if there exists a path from s 0 to t h in H st . This is equivalent to saying that for all s, t ∈ V , the flow value from s 0 to t h is at least 1 in H st . Given graph G, we thus have the following ILP formulation for the minimum h-hopset problem, using indicator variables x uv for G ∪ H (given as 1 if {u, v} ∈ G ∪ H and 0 otherwise) and variables f st uivj , representing the flow value along arc (u i , v j ) in H st : Minimize:

u =v,{u,v} / ∈E x uv (5)
Subject to:

x uv ∈ {0, 1} (6)
0 ≤ f st uivj ≤

x uv , if j = i + 1 and dG(s, u) + dG(u, v) + dG(v, t) = dG(s, t), 0, otherwise.

ui

f st vj ui - ui f st uivj =      0, for v j ∈ V h \ {s 0 , t h } +1, for v j = s 0 -1, for v j = t h , (8)
where indices s, t, u, v traverse V and indices i, j traverse {0, . . . , h}.

To obtain an LP relaxation of the above problem, we replace the integral condition x uv ∈ {0, 1} by the fractional one x uv ∈ [0, 1]. We look at the connection between the integral and fractional forms for the special case of unique shortest path graphs.

We remark that the above formulation can be seen as a generalization of the LP and ILP statement of Angelidakis et al. [START_REF] Angelidakis | Algorithmic and hardness results for the hub labeling problem[END_REF] proposed for the special case of 2-hop labeling. In the case of 2-hop labeling, Angelidakis et al. do not rely on an explicit flow formulation but use a single constraint of the simpler form w∈P st min{x sw , x wt } ≥ 1, where P st represents the set of nodes on some shortest st path in G. However, the analysis of the integrality gap does not carry over from the case of h = 2 to h > 2, i.e., as soon as there exist internal shortcuts which have neither s nor t as one of their endpoints.

Bounding Integrality Gap for Unique Shortest Path Graphs

We analyze the integrality gap of the above LP formulation for the case of unique shortest path (USP) graphs, i.e., graphs in which each pair of nodes s, t ∈ V is connected by a unique shortest path P st in G. We will occasionally identify P st with its set of nodes, and we will introduce a linear order on its vertices, writing for u, v ∈ P st that u < st v if d G (s, u) < d G (s, v); we will denote the order simply as "<" when the path P st is clear from the context. Observe that in the LP formulation, we may have f st uivj = 0 only if u < st v and j = i + 1. Thus, fixing s, t ∈ V , the flow f st = (f st uivj : u i , v j ∈ V h ) is non-zero between vertices of {P st } × {0, 1, . . . , h} only, and the flow is oriented towards t on this path.

Let (x uv , f st uivj ) be a fixed solution to the LP problem in a USP graph, with cost COST LP = u =v,{u,v} / ∈E x uv . We will show how to use this set to construct a valid hopset H ′′ for G (thus, equivalently, also solving the ILP formulation). We first apply a randomized rounding procedure following the classical scheme of Raghavan and Thomson [START_REF] Raghavan | Randomized rounding: a technique for provably good algorithms and algorithmic proofs[END_REF]. We define the family of independent random variables (x ′ uivi+1 : u, v ∈ V, i ∈ {0, . . . , h}), with x ′ uivi+1 ∈ {0, 1}. For u = v, {u, v} / ∈ E we put Pr[x ′ uivi+1 = 1] = min{Cx uv , 1}, where C ≥ 1 is a suitably chosen probability amplification parameter (we put C = 8h ln n). We will assume, without affecting the validity or cost of the solution, that

x uv = x ′ uivi+1 = 1, when u = v or {u, v} ∈ E.
We denote

H ′ = {{u, v} : u, v ∈ V ∧ u = v ∧ {u, v} / ∈ E ∧ ∃ i∈{0,...,h-1} x ′ uivi+1 = 1}. Let π : V → {1, .
. . , n} be a bijection picked uniformly at random (it is a random permutation when V = {1, . . . , n}). We define the set of shortcuts S({u, v}) associated with each pair {u, v} ∈ H ′ as the set of all pairs of nodes on path P uv , one of which is a prefix minimum on this path with respect to π, and the other of which is a suffix minimum with respect to π:

S({u, v}) := {u * , v * } : u * , v * ∈ P uv ∧ π(u * ) = min z∈P uv ,z≤ uv u * π(z) ∧ π(v * ) = min z∈P uv ,z≥ uv v * π(z) .
The obtained solution is given as the set of all such shortcuts: H ′′ := {u,v}∈H ′ S({u, v}).

Proposition 1 With probability 1 -O(1/n), set H ′′ is a hopset for G of size O(h 2 log 3 n • COST LP ).
The rest of the section is devoted to the proof of Proposition 1.

Size of the Hopset

H ′′ Proposition 2 We have |H ′′ | = O(h 2 log 3 n • COST LP ), with probability 1 -O(1/n).
Proof. We first remark that for any i ∈ {0, . . . , h -1}, by a standard application of a multiplicative Chernoff bound, we have that the following bound holds with probability 1 -O(1/n 2 ):

u =v,{u,v} / ∈E x ′ uivi+1 ≤ 2C u =v,{u,v} / ∈E x uivi+1 = O(h log n • COST LP ) It follows by a union bound over i ∈ {0, . . . , h -1} that |H ′ | = O(h 2 log n • COST LP ), with probability 1 -O(1/n).
We now proceed to bound the size of each set S({u, v}), for {u, v} ∈ H ′ . This is given precisely by the product of the size of the set of prefix minima and suffix minima of permutation π on path P uv . Denoting the random variable describing the number of prefix minima on a path as X st := |{u * ∈ P st : π(u * ) = min z∈P st ,z≤ st u * }|, we have:

|S({u, v})| = X uv • X vu .

It is well-known the number of prefix minima has expectation EX

uv = ln |P uv | + O(1) ≤ ln n + O(1)
and that the distribution of X uv is concentrated around its expectation; in particular, by a simple multiplicative Chernoff bound, we have that Pr[X uv ≤ 4 ln n] ≥ 1n -3 . Applying a union bound over all {u, v}, we have:

Pr[∀ {u,v}∈H ′ |S({u, v})| ≤ 16 ln 2 n] ≥ 1 -n -1 .
Overall, we thus have that

|H ′′ | = O(h 2 log n•COST LP •log 2 n) = O(h 2 log 3 n•COST LP ), with probability 1 -O(1/n).

Correctness of the Hopset H ′′

For fixed s, t ∈ V , the choice of x ′ uivi+1 is performed iteratively over i, as a random process. Each step i = 0, 1, . . . , h -1 of this process determines the vertex v (i+1)st ∈ P st , given inductively as:

v (i+1)st = max (< st ) {v ∈ P st : ∃ u∈P st u ≤ v (i)st ∧ x ′ uivi+1 = 1},
where we denote v (0)st := s. First of all, observe that we have the following sufficient condition for the validity of a h-hopset for the pair s, t.

Lemma 3 If v (h)st = t, then there exists a st path in G ∪ H ′′ with at most h hops whose vertices form an increasing subsequence on P st according to the order "< st ".

Proof. For i ∈ {0, . . . , h -1}, denote by u (i+1)st the vertex u used in the definition of v (i+1)st , i.e.:

u (i+1)st = max (< st ) {u ∈ P st : x ′ uiv (i+1)st i+1 = 1}.
Note that u (i+1)st ≤ v (i)st ≤ v (i+1)st . For some l ≤ h, let (φ 0 , . . . , φ l ) ⊆ (0, . . . , h), with φ 0 = 0 and φ l = h, denote a minimal subsequence of indices such that u (φi)st ≤ v (φi-1)st ≤ u (φi+1)st ≤ v (φi)st , for all i ∈ {1, . . . , l -1}. Note that each path P u (φ i+1 )st v (φ i )st is a subpath of P st by the unique shortest path condition, and consider the minimum vertex z (i)st according to permutation π on this subpath: z (i)st := arg min{π(z) : z ∈ P st ∧ u (φi+1)st ≤ z ≤ v (φi)st }. Note that z (0)st = s, z (l)st = t, and for all i ∈ {0, . . . , l -1}, we have:

u (φi+1)st ≤ z (i)st ≤ v (φi)st ≤ u (φi+2)st ≤ z (i+1)st ≤ v (φi+1)st .
We have {u (φi+1)st , v (φi+1)st } ∈ H ′ , and moreover z (i)st is a prefix minimum with respect to π on P u (φ i+1 )st v (φ i+1 )st (for the subpath P u (φ i+1 )st v (φ i )st ), whereas z (i+1)st is a prefix maximum with respect to π on P u (φ i+1 )st v (φ i+1 )st (for the subpath P u (φ i+2 )st v (φ i+1 )st ). It follows from the definition of H ′′ that {z (i)st , z (i+1)st } ∈ H ′′ . Recalling that z (i)st ≤ st z (i+1)st , z (0)st = s and z (l)st = t for some l ≤ h, the claim follows from the existence of the path (z (0)st , z (1)st , . . . , z (l)st ). The rest of the proof of correctness is devoted to showing that the event "v (h)st = t" holds with high probability. We have the following claim.

Lemma 4 Pr   u,v∈P st : u≤v (i)st , v>v (i+1)st x uv > 1 2h   < n -4 .
Proof. Denote the probability from the claim by p. Conditioned on the choice of v (1)st , . . . , v (i)st , at the beginning of step i, let w be the right-most (largest) vertex on path P st such that u,v∈P st : u≤v (i)st , v>w

x uv > 1 2h .
Directly by the definition of v (i+1)st , we have:

p = Pr[v (i+1)st ≤ w] = Pr ∀ u,v∈P st : u≤v (i)st , v>w x ′ uivi+1 = 0 = u,v∈P st : u≤v (i)st , v>w max{0, 1 -Cx uv } ≤ u,v∈P st : u≤v (i)st , v>w (1 -Cx uv ) ≤ exp   - u,v∈P st : u≤v (i)st , v>w Cx uv   < e -C/2h = n -4 .
We now consider the graph H st inferred from the (not necessarily integral) solution to the LP, given on vertex set V as the set of edges uv, such that f st uj vj+1 > 0 for some j. Each step i = 0, 1, . . . , h -1 of the considered process of random choice determines the following s 0t h -flow F (i+1)st on an edge-weighted version of graph H st , described by its flow value f

(i+1)st uj vj+1
on each arc (u j , v j+1 ) of H st as follows. F (i+1)st is set as a maximum s 0t h flow (with ties broken deterministically in an arbitrary manner) in an edge-weighting of H st such that the capacity of arc (u j , v j+1 ) is f (i)st uj vj+1 , for all arcs of H st , except for arcs (u i , v i+1 ) with v > v (i+1)st , whose capacity is set to 0. By convention, we denote f (0)st uj vj+1 := f st uj vj+1 , i.e., as the flow value on the considered arc in the optimal solution to the LP.

Denote by |F (i)st | the value of flow F (i)st . The following claim holds.

Lemma 5 Pr[|F (i+1)st | ≥ |F (i)st | -1 2h ] ≥ 1 -n -4 .
Proof. We note that for any u, v ∈ P st such that u > v (i)st we have f (i+1)st uivi+1 = 0, since in the i-th step of the considered process, the in-capacity of vertex u i is given as w∈P st f (i)st wi-1ui = 0 by the definition of the (i -1)-st step of the process.

Moreover, for any arc (u j , v j+1 ) of H st , the values f (i)st uj vj+1 are clearly non-increasing with i, thus in particular:

f (i)st uj vj+1 ≤ f (i-1)st uj vj+1 ≤ . . . ≤ f (0)st uj vj+1 ≤ x uv .
Combining the two above observations, by comparing the size of any two cuts in graph H st for its weightings in successive steps and taking into account the above observations, we obtain the following expression which is used to lower-bound |F (i+1)st |:

|F (i)st | -|F (i+1)st | ≤ u,v∈P st : v>v (i+1)st f (i)st uivi+1 = u,v∈P st : u≤v (i)st , v>v (i+1)st f (i)st uivi+1 ≤ u,v∈P st : u≤v (i)st , v>v (i+1)st
x uv Thus, applying Lemma 4 we obtain the claim.

Lemma 6 Pr[v (h)st = t] ≥ 1 -n -3 .
Proof. First note that if v (h)st = t, then v (h)st < t, and it follows that |F (h)st | = 0 because all the capacities of arcs entering node t h are equal to 0 by definition in the graph in which flow F (h)st is considered. Now, observe that using Lemma 5 and applying a union bound over i, we obtain:

Pr[|F (h)st | ≥ |F (0)st | -h 2h ] ≥ 1 -hn -4 ≥ 1 -n -3 .
Observe next that F (0)st ≥ 1 by the constraints of the LP solution, hence |F (h)st | is strictly positive with probability at least 1n -3 . Applying a union bound over all pairs s, t ∈ V , we obtain Pr[∀ s,t∈V v (h)st = t] ≥ 1n -1 . The correctness of the scheme with probability 1n -1 follows directly from Lemma 3.

We remark that the Proposition 1 implies that the h-hopset problem can be efficiently approximated by finding an optimal fractional LP solution and constructing set H ′′ .

Theorem 2 There exists a randomized polynomial-time O(poly log n)-approximation algorithm for the h-hopset problem in unique shortest path graphs, for any h ≤ O(poly log n).

Approximating Average Query Time for 3-Hopsets

In order to design an efficient distance oracle based on 3-hopsets, we follow the framework described in the preliminaries and use an LP-rounding technique to obtain sets H 1 ∪ H 2 =: H. The obtained claim relies on the notion of uniform-average query time introduced in the Preliminaries. Proof. In this case, for the ILP statement we associate with each edge uv a binary indicator variable x x (1) uv [START_REF] Angelidakis | Algorithmic and hardness results for the hub labeling problem[END_REF] Subject to:

u =v,{u,v} / ∈E x uv ≤ S (10) 0 ≤ f st uivj ≤      x (1) uv , if 2 = j = i + 1 and d G (s, u) + d G (u, v) + d G (v, t) = d G (s, t), x uv , if 2 = j = i + 1 and d G (s, u) + d G (u, v) + d G (v, t) = d G (s, t), 0, otherwise. ( 11
) ui f st vj ui - ui f st uivj =      0, for v j ∈ V h \ {s 0 , t h } +1, for v j = s 0 -1, for v j = t h , (12)
and its LP relaxation on variables x uv , x

uv takes the form of the constraint:

0 ≤ x (1) uv ≤ x uv ≤ 1,
where as usual indices s, t, u, v traverse V and indices i, j traverse {0, 1, 2, 3}.

The construction of the integral hopset H ′′ based on the LP solution takes place as in the previous Subsection (for the case of h = 3), with the exception that for the first and last (third) hop, variables

x (1)
uv should be used in place of x uv in the construction. By an analogue of Proposition 2, we have |H ′′ | = O(S log 3 n), with high probability. We consider the natural decomposition

H ′′ := H ′′ 1 ∪ H ′′ 2
according to the number of the used hop along the path, and obtain by a similar (straightforward) concentration analysis that for all u ∈ V :

deg H ′′ 1 (u) ≤ O(log 2 n) v∈V x (1) uv .
and so, computing the sum of degrees over all u:

|H ′′ 1 | ≤ O(log 2 n) v∈V
x (1) uv .

Noting that the sum on the right-hand side is precisely the minimization criterion in the LP formulation [START_REF] Angelidakis | Algorithmic and hardness results for the hub labeling problem[END_REF], we obtain the claim of the theorem. We remark that the above Theorem can be directly generalized to a notion of average query time for non-uniform query densities, in which the goal is to minimize expected query time in a model in which each node v ∈ V is assigned its relative frequency f v ∈ [0, 1], and a node pair uv is queried with frequency f u f v .

Bounded Treewidth Graphs

We now show how to obtain h-hopsets for graphs with bounded treewidth by following a classical construction for trees. We first begin with preliminaries recalling the definitions of treewidth and inverse Ackermann function.

Treewidth definition. Recall that a graph G has treewidth t if there exists a tree T whose nodes are subsets of V (G) called bags such that: |X| ≤ t + 1 for all X ∈ V (T ); for all edges uv ∈ E(G), there exists a bag X ∈ V (T ) containing both u and v (u, v ∈ X); and for all nodes u ∈ V (G), the bags containing u form a sub-tree of T . Without loss of generality, we assume that each bag contains exactly t + 1 nodes, and that two neighboring bags share exactly t nodes (the decomposition is standard). This implies |V (T )| ≤ n as each bag brings one new node. Note that removing a non-leaf bag separates the graph into several connected components. We consider that all edges of T have weight 1. For convenience, we assume that T is rooted at some bag R and define for each node u ∈ V (G) the root bag of u as the bag R u ∈ V (T ) containing u which is closest to the root.

Ackermann notation. Following [START_REF] Alon | Optimal preprocessing for answering on-line product queries[END_REF], we introduce the following variants of the Ackermann function:

   A(0, j) = 2j, for j ≥ 0 A(i, 0) = 1, for i ≥ 1 A(i, j) = A(i -1, A(i, j -1)), for i, j ≥ 1; and    B(0, j) = j 2 , for j ≥ 0 B(i, 0) = 2, for i ≥ 1 B(i, j) = B(i -1, B(i, j -1)), for i, j ≥ 1.
The kth-row inverse Ackermann function λ k (.) is defined by λ 2i (n) = min{j | A(i, j) ≥ n} and λ 2i+1 (n) = min{j | B(i, j) ≥ n} for i ≥ 0. Equivalently, we have (up to integer ceiling) λ 0

(n) = n 2 , λ 1 (n) = √ n and λ k (n) = λ * k-2 (
n) where we define for any function f :

f (0) (n) = n, f (i) (n) = f (f (i-1) (n)) for i > 0, and f * (n) = min{j | f (j) (n) ≤ 1}. Note that λ 2 (n) = log n, λ 3 (n) = log log n, λ 4 (n) = log * n and λ 5 (n) = 1
2 log * n (we omit integer ceilings). The inverse Ackermann function is defined as α

(n) = min{j | A(j, j) ≥ n}. Note that we have λ 2α(n) (n) = α(n).
We first consider the case of (weighted) trees for which the construction of h-hopsets is classical (even though the connection with hopsets was not made). It is implicit in [START_REF] Alon | Optimal preprocessing for answering on-line product queries[END_REF][START_REF] Chazelle | Computing on a free tree via complexity-preserving mappings[END_REF], explicit for unweighted trees in [START_REF] Hans | Trade-offs in non-reversing diameter[END_REF] and directed trees in [START_REF] Thorup | Parallel shortcutting of rooted trees[END_REF]. We provide a short construction which fine-grains the dependence of the hopset size on h (e.g., replacing 2h by h with respect to the asymptotic analysis in [START_REF] Alon | Optimal preprocessing for answering on-line product queries[END_REF]). The construction is based on the following folklore lemma for splitting a tree into smaller sub-trees (it can be seen as a generalization of the existence of a centroid).

Lemma 7 Given a rooted tree T with n nodes and a value p > 1, there exists a set P of at most 2p nodes such that each connected component of T \ P contains less than n/p nodes and is connected to at most two nodes in P . Set P can be computed in linear time through a bottom-up traversal of the tree.

Proof. Start with P ′ = ∅ and root T at some arbitrary node r. As long as the connected component of T \ P ′ containing root r has n/p nodes or more, add to P ′ a node u from this component such that the subtree T (u) rooted as u has size n/p or more while |T (v)| < n/p for all descendants v of u. This results in a set P ′ having at most p nodes such that the connected components of T \ P ′ have size less than n/p. Define P ′′ as the set of lowest common ancestors of any two nodes u, v ∈ P ′ . The size of P ′′ is at most p -1 since its nodes correspond to the internal nodes with two children or more in the minimal sub-tree containing P ′ which has at most p leaves. Let P = P ′ ∪ P ′′ be the union of P ′ and P ′′ . For any connected component T ′ of T \ P , there exist at most two nodes in P that are connected to nodes of T ′ in T : at most one is connected to the root r ′ of T ′ (T ′ is considered as a sub-tree of T and at most one has its parent in T ′ (if there were two such nodes, their lowest common ancestor would be in P and not in T ′ , contradicting the connectivity of T ′ ).

h-hopset construction for trees. A 1-hopset in a tree T is obtained by adding all pairs as edges with appropriate weight. For h > 1, we recursively define a h-hopset of T as follows. Select a set P of 2p nodes at most with p = n λ h-2 (n) according to Lemma 7. When h = 2, we add an edge from each node u of T to each node in P . When h > 2, we consider the forest T ′ induced by nodes in P : it has node set P and edges xy such that y is the closest ancestor of x in T that belongs to P . The weight of such an edge is defined as w ′ (x, y) = d T (x, y). We then add a (h -2)-hopset of T ′ to the construction. Additionally, we add one or two edges per node not in P : for each connected component C of T \ P , add an edge ux for each node u ∈ C and each x ∈ P connected to C. Note that Lemma 7 ensures that there are at most two such nodes x for a given component C. In both cases (h ≥ 2), we construct recursively a h-hopset of each sub-tree induced by a connected component C of T \ P . In the special case of h = 3, the (h -2)-hopsets contribute to H 2 while all edges connecting to a node in some selected set P contribute to H 1 according to the H = H 1 ∪ H 2 convention introduced in the Preliminaries.

We now state the parameters of the designed hopset for trees. We note that the O(nλ h (n)) hopset size is indeed tight for some trees. If P is a path with nodes from 1 to n, any h-hopset can be seen as a covering of intervals in [1, n] where [i, j] denotes the interval i, i+1, . . . , j of integers. More precisely, a set I of intervals h-covers [1, n] when every interval [i, j] ⊆ [1, n] is the union of at most h intervals in I [START_REF] Alon | Optimal preprocessing for answering on-line product queries[END_REF]. We can easily obtain a h-covering from any h-hopset H of the path P by associating each edge uv of P ∪ H to the interval [u, v]. A lower bound of Ω(nλ h (n)) for the size of a h-covering of [1, n] is proved in [START_REF] Alon | Optimal preprocessing for answering on-line product queries[END_REF].

Correctness of construction. The correctness of the constructed h-hopset H comes from the fact that two nodes u, v in two different connected components of T \ P both have an hopset edge to a node in P on the path P uv from u to v according to Lemma 7. Let x and y denote the nodes in P ∩ P uv that are linked to u and v respectively (ux, vy ∈ H). For h > 2, the (h -2)-hopset added in the construction implies that a path of at most h -2 hops links x to y in T ∪ H and we thus have d h T ∪H (u, v) = d T (u, v). For h = 2, we also have vx ∈ H (and uy ∈ H), and x ∈ P uv implies d 2 T ∪H (u, v) = d T (u, v).

Analysis. We claim that the resulting h-hopset has O(nλ h (n)) edges for h > 1. Recall that a 1hopset has Θ(n 2 ) edges. Note that the choice of p = n λ h-2 (n) in our construction implies that connected components created by Lemma 7 have size at most λ h-2 (n). The components created in a recursive call with recursion depth j will have size λ (j) h-2 (n). The number of recursion levels is thus min{j | λ (j) h-2 (n) ≤ 1} = λ h (n). We now show that O(n) edges are added to the construction at each recursion level. For h = 2, we have p = O(1) and the number of edges added at each recursion level is thus at most O(n). For h = 3, we have p = n λ1(n) = √ n and the (h -2)-hopset constructed on at most 2p nodes has O(n) edges. For h > 3, we proceed by induction on h: we assume that the (h -2)-hopset constructed for a tree with at most 2p nodes has O(2pλ h-2 (2p)) edges that is O(n) edges for p = n λ h-2 (n) (note that λ h-2 is non-decreasing for any h > 0).

Query time for 3-hopsets. For the special case of h = 3, we have λ 3 (n) = log log n, and the size required to represent the 3-hop data structure is S = O(n log log n) edges. Moreover, following the convention H = H 1 ∪ H 2 introduced in the Preliminaries, we note that in the adopted construction, deg H1 (v) = O(log log n) for all v ∈ V . A bound of O(log 2 log n) query time follows from the above analysis.

Linear size hopset. We can obtain a linear size 2(α(n) + 1)-hopset by splitting T into sub-trees of size at most α(n) using Lemma 7 with p = n α(n) . Two nodes in a connected component of T \ P are thus obviously linked by a path of length at most α(n) in T . Similarly as before, we link every node to the (at most 2) nodes in P connected to its component and add a 2α(n)-hopset for the forest induced by nodes in P . We thus obtain a 2(α(n) + 1)-hopset with O(n + n α(n) λ 2α(n) (n)) = O(n) edges. We now consider the case of bounded treewidth graphs. h-hopset construction for bounded treewidth graphs. Consider a graph G with treewidth t and an associated tree T . The general idea is to follow the construction of a h-hopset of T with slight modifications. Similarly to the tree case, we select a set P of at most 2p bags with p = n/t λ h-2 (n/t) according to Lemma 7. We then construct a (h -2)-hopset H T ′ of the forest T ′ induced by bags in P according to the tree construction. For each edge XY in H T ′ , we add an edge xy to the graph hopset for all x ∈ X and y ∈ Y . Such edges are called tree-hopset edges. Now for each node u, such that its root bag R u falls in a connected component of T \ P , we consider the (at most 2) bags Y ∈ P that are connected to that component and add an edge uy to the graph hopset for all y ∈ Y . Such edges are called separator edges. We then recurse on each component of T \ P until we reach subtrees of size n ′ ≤ t. We then pursue with p = n ′ λ h-2 (n ′ ) and so on recursively until reaching components of size at most 1. Finally, for each node u, we add an edge ux to the graph hopset for all x ∈ R u . Such edges are called bag edges. To construct a linear size hopset, we use a single step with p = n α(n) and a 2α(n)-hopset of T ′ . For each tree edge XY inside components of T \ P we add an edge xy to the construction for all x ∈ X and y ∈ Y such that x / ∈ Y and y / ∈ X. Such edges are also considered as tree-hopset edges. We now state the parameters of the designed hopset.

  and moreover for all u ∈ V , we have E deg H ′ (u) = O(k log D ′ ) and deg H ′ (u) = O(k log D ′ log log n + log n). We directly use set H ′ for the value D ′ := L 4 max k 6 log 12 n, considering H ′ as a 3-hopset for node pairs u, v ∈ V with d G (u, v) ≤ D ′ . So we have:

D) 1

 1 is the set of first and last hops, andH (D) 2is the set of middle hops.Set of first and last hops. For u ∈ V , let R (D) (u) be the set of nodes which lie on a shortest path of length at least D which has one of its endpoints at u, and which have minimum value of ρ among all vertices on this path at distance in [D/4, D/2] from u: R (D) (u) = v∈V :dG(u,v)≥D argmin r∈Puv,dG(u,r)∈[D/4,D/2] ρ(r) .

  4, D/2]}, has at least at most k distinct paths, |P| ≤ k. The bound on the size of set |R (D) (u)| now follows directly from its definition. From the above Lemma, it follows that for any u ∈ V , we have deg H (D) 1 (u) ≤ k. Thus summing over all the O(log log(nL max )/ log(1 + ǫ)) = O(log log(nL max ) log k) levels of the construction, we successively obtain:

Lemma 2

 2 Fix D ≥ D ′ . With probability 1-O(1/n 2 ), it holds that for all u ∈ V and for all r ∈ R (D) (u), we have ρ(r) ≤ L max /D.Proof. As noted in the proof of Lemma 1, to be included in R (D) (u), a node r must be the minimum element along one of the at most k possible paths Π v . Each such path includes all nodes on the path P uv at distance in the range [D/4, D/2] from u, where we recall that D ≥ D ′ = CL 4 max k 6 log 12 n > CL max ln 2 n, for some sufficiently large choice of constant C > 0. It follows that each path Π v contains |Π v | ≥ max{ln 2 n, CD 8Lmax } nodes. Now, taking note of the independence of the choice of random variables (ρ(w) : w ∈ Π v ), we have by a simple concentration bound that Pr[min ρ(Π v ) > L max /D] ≤ O(1/n 4 ), for a suitable choice of constant C. By taking a union bound over all paths Π v in P, and then another union bound over all u ∈ V , the claim follows.

(D) 2 ,

 2 then by the definition of H (D) 2

Theorem 3

 3 For any feasible bound S, let H OP T,S be a 3-hopset for a unique shortest path graph, which satisfies the given bound on the number of edges |H OP T,S | ≤ S and such that the uniform-average query time T (H OP T,S ) is minimized. Then, there exists a randomized polynomial-time algorithm which finds a 3-hopset H with |H ′′ | ≤ O(log 3 n)S and T (H ′′ ) ≤ O(log 4 n)T (H OP T,S ).

( 1 )

 1 uv ∈ {0, 1} stating if uv ∈ H 1 , and a second indicator variable x uv ∈ {0, 1}, withx uv ≥ x (1) uv , stating if uv ∈ H 1 ∪ H 2 .The problem of minimizing the query time of the oracle with size bound S for uniform node-pair query frequencies is now given as (compare with (5)-(8)):Minimize: u =v,{u,v} / ∈E

Table 1 :

 1 O(t log log n) O(t 2 log 2 log n) n • O(k log k log log n) O(k 2 log 2 k log 2 log n) Comparison of distance oracles based on 2-hopsets (hub labeling

	Distance oracle	Size	Treewidth t	Time	Skeleton dimension k Size Time
	2-hopset (hubs): 3-hopset:	n • O(t log n) n •	O(t + log log n)	n • O(k log n)	O(k log n)

* Supported in part by the Zuckerman STEM Leadership Program. † Supported by Irif CNRS laboratory and ANR projects DESCARTES (ANR-16-CE40-0023) and DISTANCIA (ANR-17-CE40-0015).

Theorem 4 For all h > 1, any graph with treewidth t has a h-hopset with O(tnλ h (n)) edges and a 2(α(n) + 1)-hopset with O(t 2 n) edges.

Correctness of construction. Let H denote the hopset constructed for a graph G with treewidth t and associated tree T . Consider a shortest path Q = u 0 , . . . , u k for some integer k ≥ 1. First consider the case where a bag X of T contains both u 0 and u k . Without loss of generality, we can assume than R u0 is an ancestor of R u k . As R u k lies on the path from X to R u0 , it must contain u 0 and edge u k u 0 is in H according to the last step of the above construction. Now suppose that no bag contains both u 0 and u k . Consider the first recursion call where splitting a subtree with a set P of bags separates R u0 and R u k . Consider the path from R u0 to R u k in T . Let X (resp. Y ) be the first (resp. last) bag in P on that path. Either u 0 is in X or H contains separator edges from u 0 to all nodes in X. Similarly, either u k is in Y or H contains a separator edge from u k to all nodes in Y . The (h -2)-hopset considered during that recursion call contains a path P ′ of h ′ ≤ h -2 hops from X to Y . If two consecutive bags contain u 0 and u k respectively, then H contains edge u 0 u k as a tree-hopset edge. Otherwise, let X ′ (resp. Y') be the first bag in P ′ not containing u 0 (resp. u k ). By treewidth definition, there exists bags X 1 , . . . , X k ∈ V (T ) containing edges u 0 u 1 , . . . , u k-1 u k respectively (i.e., X i contains u i-1 and u i for all i ∈ {1, . . . , k}). The shortest path Q corresponds to a walk in T from X 1 to X 2 , then to X 3 and so on. All bags on the path (in T ) from X i to X i+1 must contain u i . As that walk must go through X ′ , we can define the highest index i 0 > 0 such that u i0 ∈ X ′ . Similarly, we can define the smallest index j 0 >= i 0 such that u j0 ∈ Y ′ . Our construction H then contains separator edges u 0 u i0 and u k u j0 . When i 0 = j 0 , H contains a path of at most 2 hops with same length as Q. If two consecutive bags of P ′ contain u i0 and u j0 respectively, then H contains a tree-hopset edge u i0 u j0 . Otherwise, we can similarly define indexes i 1 , . . . , i h ′′ and j 1 , . . . , j h ′′′ with i

H then contains tree-hopset edges u i0 u i1 , . . . u i h ′′ -1 u i h ′′ , u i h ′′ u j h ′′′ , u j h ′′′ -1 u j h ′′′ , . . . , u j0 u j1 . Thus, in all cases, H contains a path of at most h hops and same length as Q.

Analysis. In the first recursion levels, a subtree of size n ′ is split into subtrees smaller than

we thus obtain subtrees of size at most t. Deeper recursion calls are similar to the tree case. The total number of recursion levels is thus

When processing a subtree of size n ′ , we build a (h -2)-hopset for a forest of at most 2p bags using O(2pλ h-2 (2p)) edges according to Proposition 3. For n ′ > t, we use p = n ′ /t λ h-2 (n ′ /t) and thus produce at most O(t 2 n ′ t ) = O(tn) tree-hopset edges. For n ′ ≤ t, we use p = n ′ λ h-2 (n ′ ) . However, for a given bag X, there are at most n ′ ≤ t nodes not in X among the other n ′ -1 bags. We thus produce at most t tree-hopset edges per bag. In both cases, each recursion level thus brings O(tn) tree-hopset edges as well as O(tn) separator edges. There are at most tn bag edges in total thus we can obtain a h-hopset with O(tnλ h (n)) edges for any graph of treewidth t. In the linear size construction, we use a single step using a 2α(n)-hopset for T ′ with O( n α(n) λ 2α(n) (n)) = O(n) edges. We thus have O(t 2 n + tn) tree-hopset edges and O(tn) separator edges.

Query time for 3-hopsets. For the special case of h = 3, we have λ 3 (n) = log log n, and the size required to represent the 3-hop data structure is S = O(tn log log n) edges. Following the convention H = H 1 ∪ H 2 , we classify tree-hopset edges in H 2 while both separator edges and bag edges are classified in H 1 . More precisely, when adding separator (or bag) edges ux for all x in a bag X, we add x as out-neighbor of u in H 1 . For any v ∈ V , we thus have deg H1 (v) = O(t log log n). The following bound on the query time follows.

Theorem 5 Any graph with treewidth t admits a 3-hopset distance oracle represented on O(tn log log n) edges of O(log n) bits, with a query time of O(t 2 log 2 log n).