Abstract
Trajectory similarity computation is an essential operation in many applications of spatial data analysis. In this paper, we study the problem of trajectory similarity computation over spatial network, where the real distances between objects are reflected by the network distance. Unlike previous studies which learn the representation of trajectories in Euclidean space, it requires to capture not only the sequence information of the trajectory but also the structure of spatial network. To this end, we propose GTS, a brand new framework that can jointly learn both factors so as to accurately compute the similarity. It first learns the representation of each point-of-interest (POI) in the road network along with the trajectory information. This is realized by incorporating the distances between POIs and trajectory in the random walk over the spatial network as well as the loss function. Then the trajectory representation is learned by a Graph Neural Network model to identify neighboring POIs within the same trajectory, together with an LSTM model to capture the sequence information in the trajectory. On the basis of it, we also develop the GTS+ extension to support similarity metrics that involve both spatial and temporal information. We conduct comprehensive evaluation on several real world datasets. The experimental results demonstrate that our model substantially outperforms all existing approaches.
Introduction
In the realm of spatial data analysis, determining the similarity between two paths is a foundational task. Applications range from optimizing logistics and delivery routes to analyzing historical traffic patterns and building recommendation engines. Traditional metrics like Dynamic Time Warping (DTW) or Edit Distance are computationally expensive ($O(n^2)$), making them impractical for massive datasets. While recent deep learning models have improved efficiency by learning low-dimensional "embeddings" of paths, they often treat trajectories as sequences of points in an empty Euclidean space.
However, real-world movement is constrained by spatial networks. Two points might be physically close but distant in terms of road travel due to infrastructure like rivers or highways. A model that ignores the road network fails to capture the true similarity of paths. Furthermore, trajectory data is often sparse, making it difficult for standard models to generalize to infrequent routes.
The GTS Framework
The authors propose the Graph-based Trajectory Similarity (GTS) framework to address these challenges by embedding the underlying spatial network directly into the learning process. The framework operates in two primary stages: POI representation learning and trajectory embedding.
1. POI Representation Learning (TraNode2Vec)
Instead of relying solely on coordinates, GTS learns embeddings for Points of Interest (POIs) or nodes within the road network. Using a "trajectory-aware random walk," the model ensures that POIs frequently appearing in the same trajectories share similar embeddings. This effectively integrates movement patterns into the map nodes themselves.
2. Trajectory Embedding (GNN-LSTM)
To handle data sparsity and capture sequential dependencies, the framework utilizes a hybrid architecture:
- GNN Layer: A Graph Neural Network (GNN) is employed to smooth a POI's embedding with information from its neighbors. This ensures the model understands the context of a street even if it has limited training data, based on its surrounding network topology.
- LSTM Layer: These network-aware embeddings are fed into a Long Short-Term Memory (LSTM) network to capture the sequential, time-dependent nature of the trajectory.
For scenarios requiring temporal analysis, the GTS+ extension incorporates a "temporal gate" (ST-LSTM) to fuse spatial data with time-of-day histograms, distinguishing between different types of trips (e.g., morning commutes vs. evening leisure trips).
Experimental Evaluation
The framework was evaluated using two large-scale real-world datasets: the Beijing (BRN) dataset, containing 28,342 POIs and 5.6 million taxi trajectories, and the New York (NRN) dataset, with 95,581 POIs and 10.5 million trajectories. The model's performance was measured using the Hitting Ratio (HR@K), which indicates how often the true most similar trajectory (as determined by traditional metrics) appears in the model's top $K$ predictions.
Key Results
- Superior Accuracy: On the Beijing dataset, GTS achieved an HR@1 of 9.21%, significantly outperforming baselines like Traj2SimVec (7.81%) and Traj2vec (5.82%).
- Spatio-Temporal Performance: In tests using GTS+, the joint training approach for spatial and temporal features achieved an HR@50 of 46.88% in New York, outperforming all non-graph-based baselines.
Conclusion and Future Work
The GTS framework demonstrates that incorporating road network topology is critical for accurate trajectory similarity computation. By separating POI embedding from trajectory embedding, the model achieves better stability and interpretability.
Future research directions include refining temporal embeddings beyond fixed 1-hour slots, reducing the one-time computational cost of building initial spatial-temporal graphs, and adapting the model to dynamic networks that account for real-time changes like road closures or accidents.
Summary updated