Walking the Dog Fast in Practice: Algorithm Engineering of the Fréchet Distance

Karl Bringmann, Marvin Künnemann, André Nusser

TL;DR

This paper presents a significantly faster and more practical algorithm for computing the Fréchet distance, a crucial measure for comparing curves like GPS trajectories. By engineering a novel "complete decider" with sophisticated pruning rules and combining it with efficient filters, the authors achieve dramatic speedups (up to 100x for decision, 30x for queries) over previous state-of-the-art methods, making Fréchet distance computations feasible for real-world applications.

What Problem Does This Paper Address?

Comparing the similarity of curves is fundamental in many fields, from analyzing GPS tracks to recognizing handwritten characters. The Fréchet distance is a popular and intuitive metric for this, often visualized as the minimum leash length needed for a person and their dog to traverse two paths simultaneously. While theoretically, computing the exact Fréchet distance is computationally expensive (near-quadratic time, with no known sub-quadratic algorithms unless certain complexity hypotheses fail), fast practical implementations are highly sought after. The ACM SIGSPATIAL GIS Cup 2017 highlighted this need, challenging participants to build near-neighbor search structures using the Fréchet distance. The bottleneck for the top competitors was precisely the core Fréchet distance decision procedure. This paper aims to bridge the gap between theoretical hardness and practical usability by developing a highly optimized and efficient implementation of the Fréchet distance decider.

Methods

The core of the paper's contribution lies in their "fast, certifying implementation for deciding the Fréchet distance." This implementation is built upon a divide-and-conquer interpretation of the classic Alt-Godau algorithm for Fréchet distance. The key innovation is the introduction of "powerful pruning rules" that significantly reduce the search space. These rules are designed to identify and discard irrelevant parts of the "free-space diagram" (the space of possible alignments between curve points).

The authors detail four main pruning rules:

  • Rule I: Empty Inputs: Handles cases where the input to a subproblem is empty, allowing for immediate termination.
  • Rule II: Shrink Box: Allows for shrinking the search box when parts of the input are known to be unreachable.
  • Rule III: Simple Boundaries: Leverages "simple boundaries" (boundaries with low complexity) to prune the search space. This involves heuristic checks (HeurClose, HeurFar) to quickly determine if curves are close or far, and then using this information to deduce reachability.
  • Rule IV: Boxes at Free-Space Diagram Boundaries: Exploits the structure of the free-space diagram's boundaries to avoid unnecessary computations.

These pruning rules are integrated into a recursive algorithm that aims to avoid full free-space exploration whenever possible. Additionally, the paper emphasizes the use of "filters" – fast, incomplete decision procedures – that are applied before the complete decider. These filters are designed to be extremely efficient, aiming for sublinear running times, and are crucial for achieving overall speedups. The implementation is also "certifying," meaning it provides a verifiable proof for each decision.

Datasets

The authors evaluated their implementation on three publicly available datasets:

  • SIGSPATIAL dataset: GPS trajectories from San Francisco.
  • Character Trajectories Data Set: Handwritten characters.
  • GeoLife data set: GPS trajectories from Microsoft Research.

They also created new benchmarks for both the decision and query settings, designed to be representative of real-world performance and to facilitate comparisons. These benchmarks involve selecting random curves and creating queries with varying distances and "neighbor ranks" (how close a curve is to the query curve in sorted order).

Key Insights and Ideas

  • Pruning is Key: The most significant insight is that sophisticated pruning rules, even if heuristic, can dramatically reduce the computational cost of the Fréchet distance decider on realistic data. This counters the theoretical worst-case hardness by exploiting practical data characteristics.
  • Filters Must Be Extremely Fast: For filters to be beneficial, they must be significantly faster than the optimized complete decider, as the overhead of running a slow filter can negate its benefits.
  • "Hard" Instances are Specific: The paper shows that instances where the Fréchet distance is difficult to compute often involve curves that are "close" in some sense, leading to complex free-space structures that require detailed exploration.
  • Certifying Algorithms Add Value: Providing a verifiable proof (certificate) for each decision enhances trust and allows for easy verification of the algorithm's correctness.

Key Results

The paper reports substantial performance improvements:

  • Decider Setting: Running time improvements of up to more than two orders of magnitude (100x) compared to the winning implementation of the GIS Cup 2017.
  • Query Setting: Speed-ups of up to a factor of 30 for near-neighbor queries compared to the top GIS Cup submissions.
  • Filter Effectiveness: The filters successfully decide a significant percentage of queries, reducing the load on the more computationally intensive complete decider (shown in Figure 12).
  • Benchmark Insights: The experiments revealed that distances larger than the exact Fréchet distance are generally harder to compute, and that curves with similar shapes tend to create more challenging instances.

Limitations and Future Work

  • Theoretical Hardness: The authors acknowledge that their approach does not overcome the theoretical worst-case hardness of the Fréchet distance problem, which is conditional on the Strong Exponential Time Hypothesis. Their improvements are primarily empirical and algorithm engineering-focused.
  • Heuristic Nature of Pruning: While effective in practice, the pruning rules are heuristic. This means they don't guarantee a speedup on all possible inputs, particularly adversarial ones.
  • Future Work: The paper suggests that further improvements could come from enhancing the filters, as some instances (particularly for the Sigspatial dataset at high neighbor ranks) are still dominated by filter computation time. Combining their optimized decider with other techniques for improving spatial hashing in the query setting is also a promising avenue.

Summary updated

BibTeX
@article{bringmann2019walking,
  author = {Karl Bringmann and Marvin Künnemann and André Nusser},
  title = {{Walking the Dog Fast in Practice: Algorithm Engineering of the Fréchet Distance}},
  journal = {J. Comput. Geom.},
  year = {2019},
}
Figure