Introduction
Measuring similarity between trajectories—sequences of points in $d$-dimensional space—is a cornerstone of modern data analysis. Applications range from tracking GPS coordinates in robotics to analyzing protein backbones in bioinformatics. The two most prominent metrics for this task are Dynamic Time Warping (DTW) and Edit Distance (ED). While DTW is prized for its ability to align sequences with varying sampling rates, ED offers robustness against outliers and noise.
The Challenge of Quadratic Complexity
The standard approach for computing both DTW and ED is dynamic programming (DP), which requires $O(n^2)$ time for sequences of length $n$. In an era of massive datasets, this quadratic cost is a dealbreaker. Furthermore, theoretical results based on the Strong Exponential Time Hypothesis (SETH) suggest that a truly subquadratic algorithm for arbitrary sequences is likely impossible. This paper investigates whether we can break this "quadratic wall" by focusing on the geometric constraints inherent in real-world data.
Leveraging Geometric Structure
The authors argue that real-world trajectories are not arbitrary. They often exhibit specific geometric properties, such as being "$\kappa$-packed" (where the curve's length within any ball is bounded) or "backbone" sequences (where points are evenly spaced). By exploiting these constraints, the authors develop the first subquadratic-time $(1+\epsilon)$-approximation schemes for DTW and ED.
The Sparsification Framework
The core innovation lies in "sparsifying" the standard $n \times n$ DP table. Instead of an exhaustive cell-by-cell calculation, the algorithm identifies regions where the optimal alignment path is most likely to reside.
- Geometric Filtering: Using Quadtrees and Well-Separated Pair Decomposition (WSPD), the algorithm identifies clusters of points that are "well-separated" in space.
- Rectangle Construction: The DP table is partitioned into a near-linear number of rectangular regions. Within each rectangle, the distance between any point in sequence $P$ and any point in sequence $Q$ is approximately constant.
- Efficient Pathfinding: By treating the DP table as a geometric search space, the authors use specialized data structures, such as Cartesian trees for range-minimum queries, to find the optimal path through these rectangles in amortized constant time.
Key Theoretical Results
The paper provides rigorous proofs for the efficiency of these approximation schemes across different classes of sequences:
- For $\kappa$-packed and $\kappa$-bounded curves: The $(1+\epsilon)$-approximation can be computed in near-linear time ($O(n \log n)$).
- For backbone sequences: The algorithm achieves subquadratic time bounds:
- DTW: $O(\frac{1}{\epsilon} n^{2-1/d} \log n)$
- ED: $O(\frac{1}{\epsilon} n^{2-1/(d+1)} \log n)$
These represent the first known algorithms to achieve these bounds for these distance measures in a geometric setting.
Discussion and Future Directions
While this work successfully bypasses the quadratic limitations for many practical scenarios, challenges remain. For "pathological" sequences that fill space (like Peano curves), the complexity still reverts to $O(n^2)$. Additionally, while the backbone results are subquadratic, achieving near-linear time for such sequences in $\mathbb{R}^2$ remains an open question. Future work could involve practical implementations to see how these algorithms perform on real-world GPS or protein data compared to existing heuristics.
Summary updated