The FastMap Algorithm for Shortest Path Computations

Liron Cohen, T. K. Satish Kumar, Tansel Uras, Sven Koenig

Abstract

We present a new preprocessing algorithm for embedding the nodes of a given edge-weighted undirected graph into a Euclidean space. The Euclidean distance between any two nodes in this space approximates the length of the shortest path between them in the given graph. Later, at runtime, a shortest path between any two nodes can be computed with A search using the Euclidean distances as heuristic. Our preprocessing algorithm, called FastMap, is inspired by the data mining algorithm of the same name and runs in near-linear time. Hence, FastMap is orders of magnitude faster than competing approaches that produce a Euclidean embedding using Semidefinite Programming. FastMap also produces admissible and consistent heuristics and therefore guarantees the generation of shortest paths. Moreover, FastMap applies to general undirected graphs for which many traditional heuristics, such as the Manhattan Distance heuristic, are not well defined. Empirically, we demonstrate that A search using the FastMap heuristic is competitive with A* search using other state-of-the-art heuristics, such as the Differential heuristic.

Introduction

Finding the shortest path between two points is a fundamental task in artificial intelligence, with applications ranging from video game navigation to robotic motion planning. While Dijkstra’s algorithm is a standard solution, it often lacks the speed required for real-time applications. A* search improves upon this by utilizing a heuristic—an estimate of the remaining distance to the goal—to guide the search.

The primary challenge in A* search is identifying a heuristic that is both efficient to compute and accurate. In grid-based environments, simple geometric distances like Manhattan or Octile distance suffice. However, for complex graphs such as social networks or intricate game levels, no obvious geometric distance exists. Existing solutions like Semidefinite Programming (SDP) are computationally expensive ($O(N^3)$), while others require excessive memory to store all-pairs shortest paths. This paper introduces the FastMap algorithm to quickly embed any undirected graph into a coordinate system where distance calculations provide effective heuristics.

The FastMap Algorithm

The authors adapted FastMap, originally a data mining tool, for graph theory. The algorithm treats graph nodes as objects and edge weights as distances, mapping them into a $K$-dimensional Euclidean space.

Euclidean Embedding and Coordinate Calculation

The core of FastMap is an iterative projection process. In each dimension, the algorithm selects two distant nodes, termed "pivots" ($O_a$ and $O_b$). Every other node $O_i$ is then projected onto the line connecting these pivots to determine its coordinate $x_i$ for that dimension.

Projection of node $O_i$ onto the line defined by pivot nodes $O_a$ and $O_b$ to determine coordinate $x_i$.

Dimensionality Reduction and $L_1$ Consistency

To capture more complex graph structures, this process repeats for $K$ dimensions. After establishing coordinates for one dimension, the distances between nodes are updated to reflect the "remaining" distance not accounted for by the current coordinates.

Iterative projection process for dimensionality reduction, mapping nodes into a new distance space $D_{new}$.

A critical contribution of this work is the modification of the standard FastMap update rule. While standard FastMap uses $L_2$ (Euclidean) distance, the authors proved that using $L_1$ (Manhattan) distances ensures the resulting heuristic is admissible (never overestimates) and consistent. This mathematical guarantee ensures that A* search will always find the optimal shortest path.

Experimental Evaluation

The algorithm was evaluated using benchmark maps from the Moving AI Lab, including game maps from Dragon Age: Origins ('lak503d', 'brc300d') and complex maze maps ('maze512-32-0').

Key Results

  • Efficiency: FastMap runs in near-linear time, making it significantly faster than SDP-based embedding methods.
  • Search Performance: On the 'lak503d' map, A* using a 10-dimensional FastMap heuristic (FM10) expanded a median of 261 nodes, outperforming the state-of-the-art Differential Heuristic (DH10), which expanded 358 nodes.
  • Memory Footprint: FastMap provides a highly compressed representation of distance information, requiring only $K$ coordinates per node rather than an $N \times N$ distance table.

Discussion and Conclusion

FastMap demonstrates that abstract graphs often possess an underlying manifold that can be recovered through geometric embedding. While highly effective on open game maps, the algorithm faces challenges in "snake-like" mazes where geometric distance poorly approximates winding paths. In such scenarios, Differential Heuristics remain superior.

Future work includes extending the admissibility proofs to directed graphs and exploring "Rapid Randomized Restarts" to optimize pivot selection. Overall, FastMap offers a powerful, near-linear time solution for generating high-quality heuristics for general undirected graphs.

Summary updated

BibTeX
@inproceedings{cohen2018fastmap,
  author = {Liron Cohen and T. K. Satish Kumar and Tansel Uras and Sven Koenig},
  title = {{The FastMap Algorithm for Shortest Path Computations}},
  booktitle = {ISAIM},
  year = {2018},
  url = {https://openreview.net/forum?id=8ZxA1TC7-2g},
}
Figure