Abstract: Shortest-path distance computation is a fundamental task in spatial computing, traditionally constrained by a trade-off between query speed, storage overhead, and accuracy. This paper introduces vdist2vec, a representation learning framework that embeds road network vertices into a high-dimensional space to predict distances via a neural network. By optimizing for distance preservation and employing specialized loss functions and ensemble models, vdist2vec achieves up to 97% better accuracy than existing approximate methods while maintaining microsecond query times and low storage costs.
Introduction
Shortest-path distance queries are the backbone of modern location-based services, such as finding the nearest point of interest or calculating travel times. However, road networks are massive, often containing millions of vertices, which creates a classic computational trade-off:
- Compute on the fly: Algorithms like Dijkstra’s are accurate but too slow for real-time ranking of thousands of points.
- Precompute everything: Storing every possible pair-wise distance requires $O(n^2)$ space, which is physically impossible for large networks (e.g., $10^{12}$ entries for a million-node graph).
- Approximate (Landmarks): Storing distances to a few "landmark" nodes saves space but often results in high error rates.
Presented at EDBT 2020, this research proposes breaking this trade-off by using representation learning to compress the network's distance information into compact vertex embeddings.
The vdist2vec Framework
The core of the approach is a framework called vdist2vec. It consists of two main components: vertex embeddings and a distance predictor. Each vertex $v_i$ in the graph is mapped to a $k$-dimensional vector. Unlike general-purpose graph embeddings (like node2vec) which focus on neighborhood structure, these embeddings are specifically optimized to preserve shortest-path distances.
As shown in the architecture above, the model uses a multi-layer perceptron (MLP) that takes two vertex embeddings as input and outputs a predicted distance $\hat{d}_{i,j}$. This treats the embedding as a learned label that captures the "spatial similarity" of nodes in a way that a simple lookup table cannot.
Handling the '1% Problem' and Scale
The authors observed that in standard models, less than 1% of vertex pairs accounted for the vast majority of the training error. To address this, they proposed two specialized variants:
- vdist2vec-L: Uses a modified loss function (inspired by Huber loss) to prevent the model from being "distracted" by the tiny fraction of vertex pairs with unusually high prediction errors, making the model significantly more accurate for the other 99% of queries.
- vdist2vec-S: An ensemble model where different "heads" of the neural network focus on different distance ranges (e.g., short hops vs. cross-city trips), improving accuracy across all scales.
To scale to networks with millions of nodes, the researchers use a "divide and conquer" strategy. They cluster the graph into small regions, train the model on "center" vertices of these clusters, and then use a smaller auxiliary network to estimate the "offset" distance for nodes within those clusters based on their geographic coordinates.
Key Results and Efficiency
The models were evaluated on six real-world road networks, ranging from small cities to the state of Florida (1.07M nodes). Key findings include:
- Superior Accuracy: On the Melbourne dataset,
vdist2vec-Sreduced the Mean Absolute Error (MAE) from 192 meters (landmark baseline) to just 5 meters. - Efficiency: Query times are in the range of 1 to 4 microseconds, making it fast enough for massive real-time applications.
- Storage: The model requires only $O(kn)$ space. For the Florida dataset, the model and embeddings fit into roughly 33 MB, whereas a full distance table would require terabytes.
Conclusion
While vdist2vec provides a highly efficient and accurate estimation of distances, it is a regression-based approach rather than an exact one. It also requires significant time to retrain if the road network changes (approximately 13 hours for a million-node network). However, for real-time spatial applications where speed and storage are critical, this learning-based approach represents a significant leap forward over traditional landmark-based approximations.
Summary updated