Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

2 Shortest Paths Algorithms

Let G = ( V, A) be a (directed) graph with a set V of vertices and a set A of arcs. Each arc ( u, v) ∈ A has an associated nonnegative length ℓ ( u, v). The length of a path is the sum of its arc lengths. In the point-to-point shortest path problem, one is given as input the graph G, a source s ∈ V, and a target t ∈ V, and must compute the length of the shortest path from s to t in G. This is also denoted as dist( s, t), the distance between s and t. The one-to-all problem is to compute the distances from a given vertex s to all vertices of the graph. The all-to-one problem is to find the distances from all vertices to s. The many-to-many problem is as follows: given a set S of sources and a set T of targets, find the distances dist( s, t) for all s ∈ S, t ∈ T. For S = T = V we have the all pairs shortest path problem.

In addition to the distances, many applications need to find the corresponding shortest paths. An out-shortest path tree is a compact representation of one-to-all shortest paths from the root r. (Likewise, the in-shortest path tree represents the all-to-one paths.) For each vertex u ∈ V, the path from r to u in the tree is the shortest path.

In this section, we focus on the basic point-to-point shortest path problem under the basic server model. We assume that all data fits in RAM. However, locality matters, and algorithms with fewer cache misses run faster. For some algorithms, we consider multi-core and machine-tailored implementations. In our model, preprocessing may be performed on a more powerful machine than queries (e. g., a machine with more memory). While preprocessing may take a long time (e. g., hours), queries need to be fast enough for interactive applications.

In this section, we first discuss basic techniques, then those using preprocessing. Since all methods discussed could in principle be applied to arbitrary graphs, we keep the description as general as possible. For intuition, however, it pays to keep road networks in mind, considering that they were the motivating application for most approaches we consider. We will explicitly consider road networks, including precise performance numbers, in Section 3.

2.1 Basic Techniques

The standard solution to the one-to-all shortest path problem is Dijkstra’s algorithm [108]. It maintains a priority queue Q of vertices ordered by (tentative) distances from s. The algorithm initializes all distances to infinity, except dist( s, s) = 0, and adds s to Q. In each iteration, it extracts a vertex u with minimum distance from Q and scans it, i. e., looks at all arcs a = ( u, v) ∈ A incident to u. For each such arc, it determines the distance to v via arc a by computing dist( s, u) + ℓ ( a). If this value improves dist( s, v), the algorithm performs an arc relaxation: it updates dist( s, v) and adds vertex v with key dist( s, v) to the prior-

Figure 1. Schematic search spaces of Dijkstra’s algorithm (left), bidirectional search (middle), and the A* algorithm (right).

ity queue Q. Dijkstra’s algorithm has the label-setting property: once a vertex u ∈ V is scanned (settled), its distance value dist( s, u) is correct. Therefore, for point-to-point queries, the algorithm may stop as soon as it scans the target t. We refer to the set of vertices S ⊆ V scanned by the algorithm as its search space. See Figure 1 for an illustration.

The running time of Dijkstra’s algorithm depends on the priority queue used. The running time is O (( |V | + |A| ) log |V | ) with binary heaps [254], improving to O ( |A| + |V | log |V | ) with Fibonacci heaps [129]. For arbitrary (non-integral) costs, generalized versions of binary heaps (such as 4-heaps or 8-heaps) tend to work best in practice [61]. If all arc costs are integers in the range <u>[0</u> , C ], multi-level buckets [103] yield a running time of O ( |A| + |V |√ log C) [8, 62] and work well in practice. For the average case, one can get an O ( |V | + |A| ) (linear) time bound [147,192]. Thorup [244] has improved the theoretical worst-case bound of Dijkstra’s algorithm to O ( |A| + |V | log log min {|V | , C} ), but the required data structure is rather involved and unlikely to be faster in practice.

In practice, one can reduce the search space using bidirectional search [67], which simultaneously runs a forward search from s and a backward search from t. The algorithm may stop as soon as the intersection of their search spaces provably contains a vertex x on the shortest path from s to t. For road networks, bidirectional search visits roughly half as many vertices as the unidirectional approach.

An alternative method for computing shortest paths is the Bellman-Ford algorithm [46, 127, 198]. It uses no priority queue. Instead, it works in rounds, each scanning all vertices whose distance labels have improved. A simple FIFO queue can be used to keep track of vertices to scan next. It is a label-correcting algorithm, since each vertex may be scanned multiple times. Although it runs in O ( |V | |A| ) time in the worst case, it is often much faster, making it competitive with Dijkstra’s algorithm in some scenarios. In addition, it works on graphs with negative edge weights.

Finally, the Floyd-Warshall algorithm [126] computes distances between all pairs of vertices in Θ( |V |3 ) time. For sufficiently dense graphs, this is faster than |V | calls to Dijkstra’s algorithm.

2.2 Goal-Directed Techniques

Dijkstra’s algorithm scans all vertices with distances smaller than dist( s, t). Goal-directed techniques, in contrast, aim to “guide” the search toward the target by avoiding the scans of vertices that are not in the direction of t. They either exploit the (geometric) embedding of the network or properties of the graph itself, such as the structure of shortest path trees toward (compact) regions of the graph.

A Search.* A classic goal-directed shortest path algorithm is A* search [156]. It uses a potential function π: V → R on the vertices, which is a lower bound on the distance dist( u, t) from u to t. It then runs a modified version of Dijkstra’s algorithm in which the priority of a vertex u is set to dist( s, u)+ π ( u). This causes vertices that are closer to the target t to be scanned earlier during the algorithm. See Figure 1. In particular, if π were an exact lower bound ( π ( u) = dist( u, t)), only vertices along shortest s – t paths would be scanned. More vertices may be visited in general but, as long as the potential function is feasible (i. e., if ℓ ( v, w) − π ( v) + π ( w) ≥ 0 for ( v, w) ∈ E), an s – t query can stop with the correct answer as soon as it is about to scan the target vertex t.

The algorithm can be made bidirectional, but some care is required to ensure correctness. A standard approach is to ensure that the forward and backward potential functions are consistent. In particular, one can combine two arbitrary feasible functions πf and πr into consistent potentials by using ( πf − πr) / 2 for the forward search and ( πr − πf) / 2 for the backward search [163]. Another approach, which leads to similar results in practice, is to change the stopping criterion instead of making the two functions consistent [148,166,216,220].

In road networks with travel time metric, one can use the geographical distance [217,237] between u and t divided by the maximum travel speed (that occurs in the network) as the potential function. Unfortunately, the corresponding bounds are poor, and the performance gain is small or non-existent [148]. In practice, the algorithm can be accelerated using more aggressive bounds (for example, a smaller denominator), but correctness is no longer guaranteed. In practice, even when minimizing travel distances in road networks, A* with geographical distance bound performs poorly compared to other modern methods.

li

t

u

lj

One can obtain much better lower bounds (and preserve Figure 2. correctness) with the ALT ( A*, landmarks, and triangle Triangle in- inequality) algorithm [148]. During a preprocessing phase, equalities for it picks a small set L ⊆ V of landmarks and stores the ALT. distances between them and all vertices in the graph. During an s – t query, it uses triangle inequalities involving the landmarks to compute a valid lower bound on dist( u, t) for any vertex u. More precisely, for any landmark li, both dist( u, t) ≥ dist( u, li) − dist( t, li) and dist( u, t) ≥ dist( li, t) − dist( li, u) hold. If several landmarks are available, one can take the maximum overall bound. See Figure 2 for an illustration. The corresponding potential function is feasible [148].

Figure 2. Triangle inequalities for ALT.

The quality of the lower bounds (and thus query performance) depends on which vertices are chosen as landmarks during preprocessing. In road networks, picking well-spaced landmarks close to the boundary of the graph leads to the best results, with acceptable query times on average [112,150]. For a small (but noticeable) fraction of the queries, however, speedups relative to bidirectional Dijkstra are minor.

Geometric Containers. Another goal-directed method is Geometric Containers. It precomputes, for each arc a = ( u, v) ∈ A, an arc label L ( a) that encodes the set Va of vertices to which a shortest path from u begins with the arc a. Instead of storing Va explicitly, L ( a) approximates this set by using geometric information (i. e., the coordinates) of the vertices in Va. During a query, if the target vertex t is not in L ( a), the search can safely be pruned at a. Schulz et al. [235] approximate the set Va by an angular sector (centered at u) that covers all vertices in Va. Wagner et al. [251] consider other geometric containers, such as ellipses and the convex hull, and conclude that bounding boxes perform consistently well. For graphs with no geometric information, one can use graph layout algorithms and then create the containers [55, 250]. A disadvantage of Geometric Containers is that its preprocessing essentially requires an all-pairs shortest path computation, which is costly.

Arc Flags. The Arc Flags approach [157, 178] is somewhat similar to Geometric Containers, but does not use geometry. During preprocessing, it partitions the graph into K cells that are roughly balanced (have similar number of vertices) and have a small number of boundary vertices. Each arc maintains a vector of K bits (arc flags), where the i -th bit is set if the arc lies on a shortest path to some vertex of cell i. The search algorithm then prunes arcs which do not have the bit set for the cell containing t. For better query performance, arc flags can be extended to nested multilevel partitions [197]. Whenever the search reaches the cell that contains t, it starts evaluating arc flags with respect to the (finer) cells of the level below. This approach works best in combination with bidirectional search [157].

The arc flags for a cell i are computed by growing a backward shortest path tree from each boundary vertex (of cell i), setting the i -th flag for all arcs of the tree. Alternatively, one can compute arc flags by running a label-correcting algorithm from all boundary vertices simultaneously [157]. To reduce preprocessing space, one can use a compression scheme that flips some flags from zero to one [58], which preserves correctness. As Section 3 will show, Arc Flags currently have the fastest query times among purely goal-directed methods for road networks. Although high preprocessing times (of several hours) have long been a drawback of Arc Flags, the recent PHAST algorithm (cf. Section 2.7) can make this method more competitive with other techniques [75].

Precomputed Cluster Distances. Another goal-directed technique is Precomputed Cluster Distances (PCD) [188]. Like Arc Flags, it is based on a (preferably balanced) partition C = ( C 1 , . . . , CK) with K cells (or clusters). The preprocessing algorithm computes the shortest path distances between all pairs of cells. The query algorithm is a pruned version of Dijkstra’s algorithm. For any vertex u visited by the search, a valid lower bound on its distance to the target is dist( s, u) + dist( C ( u) , C ( t)) + dist( v, t), where C ( u) is the cell containing u and v is the boundary vertex of C ( t) that is closest to t. If this bound exceeds the best current upper bound on dist( s, t), the search is pruned. For road networks, PCD has similar query times to ALT, but requires less space.

Compressed Path Databases. The Compressed Path Databases (CPD) [52, 53] method implicitly stores all-pairs shortest path information so that shortest paths can be quickly retrieved during queries. Each vertex u ∈ V maintains a label L ( u) that stores the first move (the arc incident to u) of the shortest path toward every other vertex v of the graph. A query from s simply scans L ( u) for t, finding the first arc ( s, u) of the shortest path (to t); it then recurses on u until it reaches t. Explicitly storing the first arc of every shortest path (in Θ( |V |2 ) space) would be prohibitive. Instead, Botea and Harabor [53] propose a lossless data compression scheme that groups vertices that share the same first move (out of u) into nonoverlapping geometric rectangles, which are then stored with u. Further optimizations include storing the most frequent first move as a default and using more sophisticated compression techniques. This leads to fast queries, but space consumption can be quite large; the method is thus dominated by other approaches. CPD can be seen as an evolution of the Spatially Induced Link-

Figure 3. Left: Multilevel overlay graph with two levels. The dots depict separator vertices in the lower and upper level. Right: Overlay graph constructed from arc separators. Each cell contains a full clique between its boundary vertices, and cut arcs are thicker.

age Cognizance (SILC) algorithm [228], and both can be seen as stronger versions of Geometric Containers.

2.3 Separator-Based Techniques

Planar graphs have small (and efficiently-computable) separators [181]. Although road networks are not planar (think of tunnels or overpasses), they have been observed to have small separators as well [79, 123, 227]. This fact is exploited by the methods in this section.

Vertex Separators. We first consider algorithms based on vertex separators. A vertex separator is a (preferably small) subset S ⊂ V of the vertices whose removal decomposes the graph G into several (preferably balanced) cells (components). This separator can be used to compute an overlay graph G′ over S. Shortcut arcs [249] are added to the overlay such that distances between any pair of vertices from S are preserved, i. e., they are equivalent to the distance in G. The much smaller overlay graph can then be used to accelerate (parts of) the query algorithm.

Schulz et al. [235] use an overlay graph over a carefully chosen sub- set S (not necessarily a separator) of “important” vertices. For each pair of vertices u, v ∈ S, an arc ( u, v) is added to the overlay if the shortest path from u to v in G does not contain any other vertex w from S. This approach can be further extended [160,236] to multilevel hierarchies. In addition to arcs between separator vertices of the same level, the overlay contains, for each cell on level i, arcs between the confining level i separator vertices and the interior level ( i − 1) separator vertices. See Figure 3 for an illustration.

Other variants of this approach offer different trade-offs by adding many more shortcuts to the graph during preprocessing, sometimes across different levels [151,164]. In particular High-Performance Multilevel Routing (HPML) [83] substantially reduces query times but significantly increases the total space usage and preprocessing time. A similar approach, based on path separators for planar graphs, was proposed by Thorup [245] and implemented by Muller and Zachariasen [205]. It works reasonably well to find approximate shortest paths on undirected, planarized versions of road networks.

Arc Separators. The second class of algorithms we consider uses arc separators to build the overlay graphs. In a first step, one computes a partition C = ( C 1 , . . . , Ck) of the vertices into balanced cells while attempting to minimize the number of cut arcs (which connect boundary vertices of different cells). Shortcuts are then added to preserve the distances between the boundary vertices within each cell.

An early version of this approach is the Hierarchical MulTi (HiTi) method [165]. It builds an overlay graph containing all boundary vertices and all cut arcs. In addition, for each pair u, v of boundary vertices in Ci, HiTi adds to the overlay a shortcut ( u, v) representing the shortest path from u to v in G restricted to Ci. The query algorithm then (implicitly) runs Dijkstra’s algorithm on the subgraph induced by the cells containing s and t plus the overlay. This approach can be extended to use nested multilevel partitions. HiTi has only been tested on grid graphs [165], leading to modest speedups. See also Figure 3.

The recent Customizable Route Planning (CRP) [76,77] algorithm uses a similar approach, but is specifically engineered to meet the requirements of real-world systems operating on road networks. In particular, it can handle turn costs and is optimized for fast updates of the cost function (metric). Moreover, it uses PUNCH [79], a graph partitioning algorithm tailored to road networks. Finally, CRP splits preprocessing in two phases: metricindependent preprocessing and customization. The first phase computes, besides the multilevel partition, the topology of the overlays, which are represented as matrices in contiguous memory for efficiency. Note that the partition does not depend on the cost function. The second phase (which takes the cost function as input) computes the costs of the clique arcs by processing the cells in bottom-up fashion and in parallel. To process a cell, it suffices to run Dijkstra’s algorithm from each boundary vertex, but the second phase is even faster using the Bellman-Ford algorithm paired with (metric-independent) contraction [100] (cf. Section 2.4), at the cost of increased space usage. Further acceleration is possible using GPUs [87]. Queries are bidirectional searches in the overlay graph, as in HiTi.

2.4 Hierarchical Techniques

Hierarchical methods aim to exploit the inherent hierarchy of road networks. Sufficiently long shortest paths eventually converge to a small arterial network of important roads, such as highways. Intuitively, once the query algorithm is far from the source and target, it suffices to only scan vertices of this subnetwork. In fact, using input-defined road categories in this way is a popular heuristic [115, 158], though there is no guarantee that it will find exact shortest paths. Fu et al. [130] give an overview of early approaches using this technique. Since the algorithms we discuss must find exact shortest paths, their correctness must not rely on unverifiable properties such as input classifications. Instead, they use the preprocessing phase to compute the importance of vertices or arcs according to the actual shortest path structure.

Contraction Hierarchies. An important approach to exploiting the hierarchy is to use shortcuts. Intuitively, one would like to augment G with shortcuts that could be used by long-distance queries to skip over “unimportant” vertices.

The Contraction Hierarchies (CH) algorithm, proposed by Geisberger et al. [142], implements this idea by repeatedly executing a vertex contraction operation. To contract a vertex v, it is (temporarily) removed from G, and a shortcut is created between each pair u, w of neighboring vertices if the shortest path from u to w is unique and contains v. During preprocessing, CH (heuristically) orders the vertices by “importance” and contracts them from least to most important.

The query stage runs a bidirectional search from s and t on G augmented by the shortcuts computed during preprocessing, but only

Figure 4. Illustrating a Contraction Hierarchies query.

visits arcs leading to vertices of higher ranks (importance). See Figure 4 for an illustration. Let ds ( u) and dt ( u) be the corresponding distance labels obtained by these upward searches (set to ∞ for vertices that are not visited). It is easy to show that ds ( u) ≥ dist( s, u) and dt ( u) ≥ dist( u, t); equality is not guaranteed due to pruning. Nevertheless, Geisberger et al. [142] prove that the highest-ranked vertex u∗ on the original s – t path will be visited by both searches, and that both its labels will be exact, i. e., ds ( u∗ ) = dist( s, u∗ ) and dt ( u∗ ) = dist( u∗ , t). Therefore, among all vertices u visited by both searches, the one minimizing ds ( u) + dt ( u) represents the shortest path. Note that, since u∗ is not necessarily the first vertex that is scanned by both searches, they cannot stop as soon as they meet.

Query times depend on the vertex order. During preprocessing, the vertex order is usually determined online and bottom-up. The overall (heuristic) goal is to minimize the number of edges added during preprocessing. One typically selects the vertex to be contracted next by considering a combination of several factors, including the net number of shortcuts added and the number of nearby vertices already contracted [142,168]. Better vertex orders can be obtained by combining the bottom-up algorithm with (more expensive) top-down offline algorithms that explicitly classify vertices hitting many shortest paths as more important [5,78]. Since road networks have very small separators [79], one can use nested dissection to obtain reasonably good orders that work for any length function [100,107]. Approximate CH has been considered as a way to accommodate networks with less inherent hierarchy [143].

CH is actually a successor of Highway Hierarchies [225] and Highway Node Routing [234], which are based on similar ideas. CH is not only faster, but also conceptually simpler. This simplicity has made it quite versatile, serving as a building block not only for other point-to-point algorithms [4,15,40,100], but also for extended queries (cf. Section 2.7) and applications (cf. Section 3.2).

Reach. An earlier hierarchical approach is Reach [154]. Reach is a centrality measure on vertices. Let P be a shortest s – t path that contains vertex u. The reach r ( u, P) of u with respect to P is defined as min { dist( s, u) , dist( u, t) } . The (global) reach of u in the graph G is the maximum reach of u over all shortest paths that contain u. Like other centrality measures [54], reach captures the importance of vertices in the graph, with the advantage that it can be used to prune a Dijkstra-based search. A reach-based s – t query runs Dijkstra’s algorithm, but prunes the search at any vertex u for which both dist( s, u) > r ( u) and dist( u, t) > r ( u) hold; the shortest s – t path provably does not contain u. To check these conditions, it suffices [149] to run bidirectional searches, each using the radius of the opposite search as a lower bound on dist( u, t) (during the forward search) or dist( s, u) (backward search).

Reach values are determined during the preprocessing stage. Computing exact reaches requires computing shortest paths for all pairs of vertices, which is too expensive on large road networks. But the query is still correct if r ( u) represents only an upper bound on the reach of u. Gutman [154] has shown that such bounds can be obtained faster by computing partial shortest path trees. Goldberg et al. [149] have shown that adding shortcuts to the graph effectively reduces the reaches of most vertices, drastically speeding up both queries and preprocessing and making the algorithm practical for continent-sized networks.

2.5 Bounded-Hop Techniques

The idea behind bounded-hop techniques is to precompute distances between pairs of vertices, implicitly adding “virtual shortcuts” to the graph. Queries can then return the length of a virtual path with very few hops. Furthermore, they use only the precomputed distances between pairs of vertices, and not the input graph. A naïve approach is to use single-hop paths, i. e., precompute the distances among all pairs of vertices u, v ∈ V. A single table lookup then suffices to retrieve the shortest distance. While the recent PHAST algorithm [75] has made precomputing all-pairs shortest paths feasible, storing all Θ( |V |2 ) distances is prohibitive already for medium-sized road networks. As we will see in this section, considering paths with slightly more hops (two or three) leads to algorithms with much more reasonable trade-offs.

Labeling Algorithms. We first consider labeling algorithms [215]. During preprocessing, a label L ( u) is computed for each vertex u of the graph, such that, for any pair u, v of vertices, the distance dist( u, v) can be determined by only looking at the labels L ( u) and L ( v). A natural special case of this approach is Hub Labeling (HL) [64, 135], in which the label L ( u) associated with vertex u consists of a set of vertices (the hubs of u), together with their distances from u. These labels are chosen such that they obey the cover property: for any pair ( s, t) of vertices, L ( s) ∩ L ( t) must contain at least one vertex on the shortest s – t path. Then, the distance dist( s, t) can be determined in linear (in the label size) time by evaluating dist( s, t) = min { dist( s, u) + dist( u, t) | u ∈ L ( s) and u ∈ L ( t) } . See Figure 5 for an illustration. For directed graphs, the label associated with u is actually split in two: the forward label Lf ( u) has distances from u to the hubs, while the backward label Lb ( u) has distances from the hubs to u; the shortest s – t path has a hub in Lf ( s) ∩ Lb ( t).

Although the required average label size can be Θ( |V | ) in general [135], it can be significantly smaller for some graph classes. For road networks, Abraham et al. [4] have shown that one can obtain good results by defining the label of vertex u as the (upward) search space of a CH query from u (with suboptimal entries removed). In general, any vertex ordering fully defines a labeling [5], and an ordering can be converted into the corresponding labeling efficiently [5,12]. The CHinduced order works well for road networks. For even smaller labels, one can pick the most important vertices greedily, based on how many shortest paths they hit [5]. A sampling version of this greedy approach works efficiently for a wide range of graph classes [78].

s

t

Figure 5. Illustrating hub labels of vertices s (diamonds) and t (squares).

Note that, if labels are sorted by hub ID, a query consists of a linear sweep over two arrays, as in mergesort. Not only is this approach very simple, but it also has an almost perfect locality of access. With careful engineering, one does not even have to look at all the hubs in a label [4]. As a result, HL has the fastest known queries for road networks, taking roughly the time needed for five accesses to main memory (see Section 3.1). One drawback is space usage, which, although not prohibitive, is significantly higher than for competing methods. By combining common substructures that appear in multiple labels, Hub Label Compression (HLC) [82] (see also [78]) reduces space usage by an order of magnitude, at the expense of higher query times.

Transit Node Routing. The Transit Node Routing (TNR) [15, 28, 30, 224] technique uses distance tables on a subset of the vertices. During preprocessing, it selects a small set T ⊆ V of transit nodes and computes all pairwise distances between them. From those, it computes, for each vertex u ∈ V \ T, a relevant set of access nodes A ( u) ⊆ T. A transit node v ∈ T is an access node of u if there is a shortest path P from u in G such that v is the first transit node contained in P. In addition to the vertex itself, preprocessing also stores the distances between u and its access nodes.

An s – t query uses the distance table to select the path that minimizes the combined s – a ( s)– a ( t)– t distance, where a ( s) ∈ A ( s) and a ( t) ∈ A ( t) are access nodes. Note that the result is incorrect if the shortest path does not contain a vertex from T. To account for such cases, a locality filter decides whether the query might be local (i. e., does not contain a vertex from T). In that case, a fallback shortest path algorithm (typically CH) is run to compute the correct distance. Note that TNR is still correct even if the locality filter occasionally misclassifies a global query as local. See Figure 6 for an illustration of a TNR query. Interestingly, global TNR queries (which use the distance tables) tend to be faster than local ones (which perform graph searches). To accelerate local queries, TNR can be extended to multiple (hierarchical) layers of transit (and access) nodes [28,224].

The choice of the transit node set is crucial to the performance of the algorithm. A natural approach is to select vertex separators or boundary vertices of arc separators as transit nodes. In particular, using grid-based separators yields natural locality filters and works well enough in practice for road networks [28]. (Although an optimized preprocessing routine for this grid-based approach was later shown to have a flaw that could potentially result in suboptimal queries [256], the version with slower preprocessing reported in [28] is correct and achieves the same query times.)

For better performance [3, 15, 142, 224], one can pick as transit nodes vertices that are classified as important by a hierarchical speedup technique (such as CH). Locality filters are less straightforward in such cases: although one can still use geographical distances [142,224], a graph-based approach considering the Voronoi regions [189] induced by transit nodes tends to be significantly more accurate [15]. A theoretically justified TNR variant [3] also picks important vertices as transit nodes and has a natural graph-based locality filter, but is impractical for large networks.

Pruned Highway Labeling. The Pruned Highway Labeling (PHL) [11] algorithm can be seen as a hybrid between pure labeling and transit nodes. Its preprocessing routine decomposes the input into disjoint shortest paths, then computes a label for each vertex v containing the distance from v to vertices in a small subset of such paths. The labels are such that any shortest s – t path can be expressed as s – u – w – t, where u – w is a subpath of a path P that belongs to the labels of s and t. Queries are thus similar to HL, finding the lowest-cost intersecting path. For efficient preprocessing, the algorithm uses the pruned labeling technique [12]. Although this method has some similarity with Thorup’s distance oracle for planar graphs [245], it does not require planarity. PHL has only been evaluated on undirected graphs, however.

Distance Table

Figure 6. Illustrating a TNR query. The access nodes of s ( t) are indicated by three (two) dots. The arrows point to the respective rows/columns of the distance table. The highlighted entries correspond to the access nodes which minimize the combined s – t distance.

2.6 Combinations

Since the individual techniques described so far exploit different graph properties, they can often be combined for additional speedups. This section describes such hybrid algorithms. In particular, early results [161, 235] considered the combination of Geometric Containers, multilevel overlay graphs, and (Euclidean-based) A* on transportation networks, resulting in speedups of one or two orders of magnitude over Dijkstra’s algorithm.

More recent studies have focused on combining hierarchical methods (such as CH or Reach) with fast goal-directed techniques (such as ALT or Arc Flags). For instance, the REAL algorithm combines Reach and ALT [149]. A basic combination is straightforward: one simply runs an ALT query with additional pruning by reach (using the ALT lower bounds themselves for reach evaluations). A more sophisticated variant uses reach-aware landmarks: landmarks and their distances are only precomputed for vertices with high reach values. This saves space (only a small fraction of the graph needs to store landmark distances), but requires two-stage queries (goal direction is only used when the search is far enough from both source and target).

A similar space-saving approach is used by Core-ALT [40,88]. It first computes an overlay graph for the core graph, a (small) subset (e. g., 1 %) of vertices (which remain after “unimportant” ones are contracted), then computes landmarks for the core vertices only. Queries then work in two stages: first plain bidirectional search, then ALT is applied when the search is restricted to the core. The (earlier) HH* approach [95] is similar, but uses Highway Hierarchies [225] to determine the core.

Another approach with two-phase queries is ReachFlags [40]. During preprocessing, it first computes (approximate) reach values for all vertices in G, then extracts the subgraph H induced by all vertices whose reach value exceeds a certain threshold. Arc flags are then only computed for H, to be used in the second phase of the query.

The SHARC algorithm [39] combines the computation of shortcuts with multilevel arc flags. The preprocessing algorithm first determines a partition of the graph and then computes shortcuts and arc flags in turn. Shortcuts are obtained by contracting unimportant vertices with the restriction that shortcuts never span different cells of the partition. The algorithm then computes arc flags such that, for each cell C, the query uses a shortcut arc if and only if the target vertex is not in C. Space usage can be reduced with various compression techniques [58]. Note that SHARC is unidirectional and hierarchical: arc flags not only guide the search toward the target, but also vertically across the hierarchy. This is useful when the backward search is not well defined, as in time-dependent route planning (discussed in Section 2.7).

Combining CH with Arc Flags results in the CHASE algorithm [40]. During preprocessing, a regular contraction hierarchy is computed and the search graph that includes all shortcuts is assembled. The algorithm then extracts the subgraph H induced by the top k vertices according to the contraction order. Bidirectional arc flags (and the partition) are finally computed on the restricted subgraph H. Queries then run in two phases. Since computing arc flags was somewhat slow, k was originally set to a small fraction (about 5 %) of the total number |V | of vertices [40]. More recently, Delling et al. showed that PHAST (see Section 2.7) can compute arc flags fast enough to allow k to be set to |V | , making CHASE queries much simpler (single-pass), as well as faster [75].

Finally, Bauer et al. [40] combine Transit Node Routing with Arc Flags to obtain the TNR+AF algorithm. Recall that the bottleneck of the TNR query is performing the table lookups between pairs of access nodes from A ( s) and A ( t). To reduce the number of lookups, TNR+AF’s preprocessing decomposes the set of transit nodes T into k cells. For each vertex s and access node u ∈ A ( s), it stores a k -bit vector, with bit i indicating whether there exists a shortest path from s to cell i through u. A query then only considers the access nodes from s that have their bits set with respect to the cells of A ( t). A similar pruning is done at the target.

2.7 Extensions

In various applications, one is often interested in more than just the length of the shortest path between two points in a static network. Most importantly, one should also be able to retrieve the shortest path itself. Moreover, many of the techniques considered so far can be adapted to compute batched shortest paths (such as distance tables), to more realistic scenarios (such as dynamic networks), or to deal with multiple objective functions. In the following, we briefly discuss each of these extensions.

2.7.1 Path Retrieval

Our descriptions so far have focused on finding only the length of the shortest path. The algorithms we described can easily be augmented to provide the actual list of edges or vertices on the path. For techniques that do not use shortcuts (such as Dijkstra’s algorithm, A* search, or Arc Flags), one can simply maintain a parent pointer for each vertex v, updating it whenever the distance label of v changes. When shortcuts are present (such as in CH, SHARC, or CRP), this approach gives only a compact representation of the shortest path (in terms of shortcuts). The shortcuts then need to be unpacked. If each shortcut is the concatenation of two other arcs (or shortcuts), as in CH, storing the middle vertex [142] of each shortcut allows for an efficient (linear-time) recursive unpacking of all shortcuts on the output path. If shortcuts are built from multiple arcs (as for CRP or SHARC), one can either store the entire sequence for each shortcut [225] or run a local (bidirectional) Dijkstra search from its endpoints [77]. These two techniques can be used for bounded-hop algorithms as well.

2.7.2 Batched Shortest Paths

Some applications require computing multiple paths at once. For example, advanced logistics applications may need to compute all distances between a source set S and a target set T. This can be trivially done with |S| · |T | point-to-point shortest-path computations. Using a hierarchical speedup technique (such as CH), this can be done in time comparable to O ( |S| + |T | ) point-to-point queries in practice, which is much faster. First, one runs a backward upward search from each ti ∈ T; for each vertex u scanned during the search from ti, one stores its distance label dti ( u) in a bucket β ( u). Then, one runs a forward upward search from each sj ∈ S. Whenever such a search scans a vertex v with a non-empty bucket, one searches the bucket and checks whether dsj ( v) + dti ( v) improves the best distance seen so far between sj and ti. This bucket-based approach was introduced for Highway Hierarchies [172], but can be used with any other hierarchical speedup technique (such as CH) and even with hub labels [81]. When the bucketbased approach is combined with a separator-based technique (such as CRP), it is enough to keep buckets only for the boundary vertices [99]. Note that this approach can be used to compute one-to-many or many-to-many distances.

Some applications require one-to-all computations, i. e., finding the distances from a source vertex s to all other vertices in the graph. For this problem, Dijkstra’s algorithm is optimal in the sense that it visits each edge exactly once, and hence runs in essentially linear time [147]. However, Dijkstra’s algorithm has bad locality and is hard to parallelize, especially for sparse graphs [186, 193]. PHAST [75] builds on CH to improve this. The idea is to split the search in two phases. The first is a forward upward search from s, and the second runs a linear scan over the shortcut-enriched graph, with distance values propagated from more to less important vertices. Since the instruction flow of the second phase is (almost) independent of the source, it can be engineered to exploit parallelism and improve locality. In road networks, PHAST can be more than an order of magnitude faster than Dijkstra’s algorithm, even if run sequentially, and can be further accelerated using multiple cores and even GPUs. This approach can also be extended to the one-to-many problem, i. e., computing distances from a source to a subset of predefined targets [81]. Similar techniques can also be applied with graph separators (instead of CH), yielding comparable query times but with faster (metric-dependent) preprocessing [113].

2.7.3 Dynamic Networks

Transportation networks tend to be dynamic, with unpredictable delays, traffic, or closures. If one assumes that the modified network is stable for the foreseeable future, the obvious approach for speedup techniques to deal with this is to rerun the preprocessing algorithm. Although this ensures queries are as fast as in the static scenario, it can be quite costly. As a result, four other approaches have been considered.

It is often possible to just “repair” the preprocessed data instead of rebuilding it from scratch. This approach has been tried for various techniques, including Geometric Containers [251], ALT [96], Arc Flags [66], and CH [142,234], with varying degrees of success. For CH, for example, one must keep track of dependencies between shortcuts, partially rerunning the contraction as needed. Changes that affect less important vertices can be dealt with faster.

Another approach is to adapt the query algorithms to work around the “wrong” parts of the preprocessing phase. In particular, ALT is resilient to increases in arc costs (due to traffic, for example): queries remain correct with the original preprocessing, though query times may increase [96]. Less trivially, CH queries can also be modified to deal with dynamic changes to the network [142,234] by allowing the search to bypass affected shortcuts by going “down” the hierarchy. This is useful when queries are infrequent relative to updates.

A third approach is to make the preprocessing stage completely metricindependent, shifting all metric-dependent work to the query phase. Funke et al. [131] generalize the multilevel overlay graph approach to encode all k -hop paths (for small k) in an overlay graph. Under the assumption that edge costs are defined by a small number of physical parameters (as in simplified road networks) this allows setting the edge costs at query time, though queries become significantly slower.

For more practical queries, the fourth approach splits the preprocessing phase into metric-independent and metric-dependent stages. The metricindependent phase takes as input only the network topology, which is fairly stable. When edge costs change (which happens often), only the (much cheaper) metric-dependent stage must be rerun, partially or in full. This concept can again be used for various techniques, with ALT, CH, and CRP being the most prominent. For ALT, one can keep the landmarks, and just recompute the distances to them [96,112]. For CH, one can keep the ordering, and just rerun contraction [107,142]. For CRP, one can keep the partitioning and the overlay topology, and just recompute the shortcut lengths using a combination of contraction and graph searches [77]. Since the contraction is metric-independent, one can precompute and store the sequence of contraction operations and reexecute them efficiently whenever edge lengths change [77,87]. The same approach can be used for CH with metric-independent orders [107].

2.7.4 Time-Dependence

In real transportation networks, the best route often depends on the departure time in a predictable way [102]. For example, certain roads are consistently congested during rush hours, and certain buses or trains run with different frequencies during the day. When one is interested in the earliest possible arrival given a specified departure time (or, symmetrically, the latest departure), one can model this as the time-dependent shortest path problem, which assigns travel time functions to (some of) the edges, representing how long it takes to traverse them at each time of the day. Dijkstra’s algorithm still works [65] as long as later departures cannot lead to earlier arrivals; this non-overtaking property is often called firstin first-out (FIFO). Although one must deal with functions instead of scalars, the theoretical running time of Dijkstra-based algorithms can still be bounded [71,128]. Moreover, many of the techniques described so far work in this scenario, including bidirectional ALT [88, 207], CH [32], or SHARC [72]. Recently, Kontogiannis and Zaroliagis [175] have introduced a theoretical (approximate) distance oracle with sublinear running time. Other scenarios (besides FIFO with no waiting at vertices) have been studied [69, 70, 208, 209], but they are less relevant for transportation networks.

There are some challenges, however. In particular, bidirectional search becomes more complicated (since the time of arrival is not known), requiring changes to the backward search [32,207]. Another challenge is that shortcuts become more space-consuming (they must model a more complicated travel time function), motivating compression techniques that do not sacrifice correctness, as demonstrated for SHARC [58] or CH [32]. Batched shortest paths can be computed in such networks efficiently as well [141].

Time-dependent networks motivate some elaborate (but still natural) queries, such as finding the best departure time in order to minimize the total time in transit. Such queries can be dealt with by range searches, which compute the travel time function between two points. There ex- ist Dijkstra-based algorithms [71] for this problem, and most speedup techniques can be adapted to deal with this as well [32,72].

Unfortunately, even a slight deviation from the travel time model, where total cost is a linear combination of travel time and a constant cost offset, makes the problem NP-hard [9, 33]. However, a heuristic adaptation of time-dependent CH shows negligible errors in practice [33].

2.7.5 Multiple Objective Functions

Another natural extension is to consider multiple cost functions. For example, certain vehicle types cannot use all segments of the transportation network. One can either adapt the preprocessing such that these edge restrictions can be applied during query time [140], or perform a metric update for each vehicle type.

Also, the search request can be more flexible. For example, one may be willing to take a more scenic route even if the trip is slightly longer. This can be dealt with by performing a multicriteria search. In such a search, two paths are incomparable if neither is better than the other in all criteria. The goal is to find a Pareto set, i. e., a maximum set of incomparable paths. Such sets of shortest paths can be computed by extensions of Dijkstra’s algorithm; see [117] for a survey on multicriteria combinatorial optimization. More specifically, the Multicriteria Label-Setting (MLS) algorithm [155,187,196,243] extends Dijkstra’s algorithm by keeping, for each vertex, a bag of nondominated labels. Each label is represented as a tuple, with one entry per optimization criterion. The priority queue maintains labels instead of vertices, typically ordered lexicographically. In each iteration, it extracts the minimum label L and scans the incident arcs a = ( u, v) of the vertex u associated with L. It does so by adding the cost of a to L and then merging L into the bag of v, eliminating possibly dominated labels on the fly. In contrast, the Multi-Label-Correcting (MLC) algorithm [68,98] considers the whole bag of nondominated labels associated with u at once when scanning the vertex u. Hence, individual labels of u may be scanned multiple times during one execution of the algorithm. Both MLS and MLC are fast enough as long as the Pareto sets are small [109,204]. Unfortunately, Pareto sets may contain exponentially many solutions, even for the restricted case of two optimization criteria [155], which makes it hard to achieve large speedups [47,97]. To reduce the size of Pareto sets, one can relax domination. In particular, (1+ ε)-Pareto sets have provable polynomial size [212] and can be computed efficiently [182,246,253]. Moreover, large Pareto sets open up a potential for parallelization that is not present for a single objective function [124,222].

A reasonable alternative [138] to multicriteria search is to optimize a linear combination αc 1 + (1 − α) c 2 of two criteria ( c 1 , c 2), with the parameter α set at query time. Moreover, it is possible to efficiently compute the values of α where the path actually changes. Funke and Storandt [133] show that CH can handle such functions with polynomial preprocessing effort, even with more than two criteria.

2.8 Theoretical Results

Most of the algorithms mentioned so far were developed with practical performance in mind. Almost all methods we surveyed are exact: they provably find the exact shortest path. Their performance (in terms of both preprocessing and queries), however, varies significantly with the input graph. Most algorithms work well for real road networks, but are hardly faster than Dijkstra’s algorithm on some other graph classes. This section discusses theoretical work that helps understand why the algorithms perform well and what their limitations are.

Most of the algorithms considered have some degree of freedom during preprocessing (such as which partition, which vertex order, or which landmarks to choose). An obvious question is whether one could efficiently determine the best such choices for a particular input so as to minimize the query search space (a natural proxy for query times). Bauer et al. [36] have determined that finding optimal landmarks for ALT is NP-hard. The same holds for Arc Flags (with respect to the partition), SHARC (with respect to the shortcuts), Multilevel Overlay Graphs (with respect to the separator), Contraction Hierarchies (with respect to the vertex order), and Hub Labels (with respect to the hubs) [252]. In fact, minimizing the number of shortcuts for CH is APX-hard [36,194]. For SHARC, however, a greedy factor- k approximation algorithm exists [38]. Deciding which k shortcuts (for fixed k) to add to a graph in order to minimize the SHARC search space is also NP-hard [38]. Bauer et al. [35] also analyze the preprocessing of Arc Flags in more detail and on restricted graph classes, such as paths, trees, and cycles, and show that finding an optimal partition is NP-hard even for binary trees.

Besides complexity, theoretical performance bounds for query algorithms, which aim to explain their excellent practical performance, have also been considered. Proving better running time bounds than those of Dijkstra’s algorithm is unlikely for general graphs; in fact, there are inputs for which most algorithms are ineffective. That said, one can prove nontrivial bounds for specific graph classes. In particular, various authors [37, 194] have independently observed a natural relationship between CH and the notions of filled graphs [214] and elimination trees [232]. For planar graphs, one can use nested dissection [180] to build a CH order leading to O ( |V | log |V | ) shortcuts [37, 194]. More generally, for minor-closed graph classes with balanced O (� |V | )-separators, the search space is bounded by O (� |V | ) [37]. Similarly, on graphs with treewidth k, the search space of CH is bounded by O ( k log |V | ) [37].

Road networks have motivated a large amount of theoretical work on algorithms for planar graphs. In particular, it is known that planar graphs have separators of size O ( � |V | ) [180,181]. Although road networks are not strictly planar, they do have small separators [79,123], so theoretically efficient algorithms for planar graphs are likely to also perform well in road networks. Sommer [238] surveys several approximate methods with various trade-offs. In practice, the observed performance of most speedup techniques is much better on actual road networks than on arbitrary planar graphs (even grids). A theoretical explanation of this discrepancy thus requires a formalization of some property related to key features of real road networks.

One such graph property is Highway Dimension, proposed by Abraham et al. [3] (see also [1,7]). Roughly speaking, a graph has highway dimension h if, at any scale r, one can hit all shortest paths of length at least r by a hitting set S that is locally sparse, in the sense that any ball of radius r has at most h elements from S. Based on previous experimental observations [30], the authors [7] conjecture that road networks have small highway dimension. Based on this notion, they establish bounds on the performance of (theoretically justified versions of) various speedup techniques in terms of h and the graph diameter D, assuming the graph is undirected and that edge lengths are integral. More precisely, after running a polynomial-time preprocessing routine, which adds O ( h log h log D) shortcuts to G, Reach and CH run in O (( h log h log D)2 ) time. Moreover, they also show that HL runs in O ( h log h log D) time and long-range TNR queries take O ( h2 ) time. In addition, Abraham et al. [3] show that a graph with highway dimension h has doubling dimension log( h + 1), and Kleinberg et al. [171] show that landmark-based triangulation yields good bounds for most pairs of vertices of graphs with small doubling dimension. This gives insight into the good performance of ALT in road networks.

The notion of highway dimension is an interesting application of the scientific method. It was originally used to explain the good observed performance of CH, Reach, and TNR, and ended up predicting that HL (which had not been implemented yet) would have good performance in practice.

Generative models for road networks have also been proposed and analyzed. Abraham et al. [3,7] propose a model that captures some of the properties of road networks and generates graphs with provably small highway dimension. Bauer et al. [42] show experimentally that several speedup techniques are indeed effective on graphs generated according to this model, as well as according to a new model based on Voronoi diagrams. Models with a more geometric flavor have been proposed by Eppstein and Goodrich [123] and by Eisenstat [118].

Besides these results, Rice and Tsotras [220] analyze the A* algorithm and obtain bounds on the search space size that depend on the underestimation error of the potential function. Also, maintaining and updating multilevel overlay graphs have been theoretically analyzed in [57]. For Transit Node Routing, Eisner and Funke [120] propose instance-based lower bounds on the size of the transit node set. For labeling algorithms, bounds on the label size for different graph classes are given by Gavoille et al. [135]. Approximation algorithms to compute small labels have also been studied [16, 64, 80]; although they can find slightly better labels than faster heuristics [5,78], their running time is prohibitive [80].

Because the focus of this work is on algorithm engineering, we refrain from going into more detail about the available theoretical work. Instead, we refer the interested reader to overview articles with a more theoretical emphasis, such as those by Sommer [238], Zwick [261], and Gavoille and Peleg [134].