# The Hub Labeling Algorithm

## Abstract

Given a weighted graph, a distance oracle takes as an input a pair of vertices and returns the distance between them. The labeling approach to distance oracle design is to precompute a label for every vertex so that the distances can be computed from the corresponding labels, without looking at the graph. In the *hub labeling algorithm (HL)*, a vertex label consists of a set of other vertices (hubs) with distances to the hubs. We survey theoretical and experimental results on HL.

Although computing optimal hub labels is hard, in polynomial time one can approximate them up to a factor of *O*(log*n*). This can be done for the total label size (i.e., memory required to store the labels), the maximum label size (which determines the worst-case query time), and in general for an *L* _{ p } norm of the vector induced by the vertex label sizes. One can also simultaneously approximate *L* _{ p } and *L* _{ q } norms.

Hierarchical labels are a special class of HL for which the relationship ”*v* is a hub of *w*” is a partial order. For networks with a small highway dimension, one can compute provably small hierarchical labels in polynomial time.

While some graphs admit small labels, there are graphs for which the labels are large. Furthermore, one can prove that for some graphs hierarchical labels are significantly larger than the general ones.

A heuristic for computing hierarchical labels leads to the fastest known implementation of a distance oracle for road networks. One can use label compression to trade off time for space, making the algorithm practical for a wider range of applications. We give experimental results showing that the heuristic hierarchical labels are efficient on road networks as well as on some other graph classes, but not on all graphs.

We also discuss efficient implementations of the provably good approximation algorithms. Although not as fast as the hierarchical heuristic, the algorithms can solve moderate-size problems. For some graph classes, the theoretically justified algorithms compute significantly smaller labels, although for many graphs the label size difference is very small.