Top-k Representative Similar Subtrajectory Query (TRSSQ)
- The paper presents a graph-based algorithm that avoids full-dataset scanning by extracting each trajectory's best matching subsegment, significantly boosting query efficiency.
- It introduces a dual-layer graph indexing framework (GARI and CNDI) combined with a dynamic programming-based similarity measure for rapid subtrajectory matching.
- Empirical evaluations show that TRSSQ achieves retrieval accuracy over 90% and up to two orders of magnitude speedup compared to traditional methods.
Top- Representative Similar Subtrajectory Query (TRSSQ) is a trajectory-mining query problem that seeks the most representative subtrajectories similar to a query trajectory. In the formulation studied in "GTRSS: Graph-based Top- Representative Similar Subtrajectory Query" (Ge et al., 7 Jul 2025), each data trajectory contributes a single representative subtrajectory, defined as the contiguous segment with maximum similarity to the query, and the TRSSQ result consists of the distinct trajectories whose representative subtrajectories attain the largest similarity scores. The problem is motivated by the observation that existing methods rely on costly filtering-validation frameworks, resulting in slow response times, and the cited work proposes a graph-based alternative that avoids full-dataset scanning and heavy computation (Ge et al., 7 Jul 2025).
1. Formalization of TRSSQ
A trajectory of length is defined as a sequence of points
with timestamp omitted for simplicity. A database of trajectories is
A subtrajectory is any contiguous segment
Given a data trajectory and a query 0, the representative similar subtrajectory is defined as
1
where 2 is the similarity measure. Its score is
3
The TRSSQ objective is then expressed over the set of representative subtrajectories 4 extracted from the database trajectories. For a requested top-5, the target result is
6
Equivalently, if 7, then
8
This formulation places the query emphasis on per-trajectory best-matching contiguous segments rather than on full-trajectory similarity. A plausible implication is that TRSSQ is tailored to settings in which only part of a trajectory is relevant to the query, while still enforcing diversity at the trajectory level by selecting distinct source trajectories.
2. Data Trajectory Similarity Metric
The cited framework introduces the Data Trajectory Similarity Metric (DTSM) because traditional measures such as DTW, EDR, and ERP compute whole-trajectory similarity but cannot directly measure the best aligned subsegments between two arbitrary trajectories (Ge et al., 7 Jul 2025). DTSM addresses this by identifying the single most similar subtrajectory pair.
The overall DTSM definition is
9
where 0 is a subtrajectory-to-subtrajectory similarity score. The maximizing pair is the most similar subtrajectory pair.
DTSM uses a point-pair matching rule parameterized by a threshold 1. With
2
and subsegments 3, 4, it counts
5
and
6
The corresponding similarity is
7
For efficient computation, the method constructs a matrix 8,
9
It then defines a recursive dynamic-programming quantity
0
where
1
The paper specifies six alignment cases, denoted C1–C6, that govern the transition structure.
A central pruning rule states that if 2, then no subsegment beginning at 3 can exceed 4: 5 The paper proves this rule by induction. Algorithm 1 implements the DP with memoization and early termination. Its worst-case complexity is reported as 6 in practice, versus 7 if done naively. This suggests that DTSM is not merely a scoring function but also a computational device that makes large-scale subtrajectory retrieval operationally feasible.
3. Dual-layer graph indexing
The GTRSS framework builds a dual-layer graph index in an offline phase. The two directed graphs are GARI, the Global Aggregated Representative Index, and CNDI, the Comprehensive Node Detail Index. In both layers, trajectories are nodes, and edges connect trajectories that are likely to share top-8 subsegments (Ge et al., 7 Jul 2025).
The upper layer, GARI, is built through Representative Node Selection and Aggregation (RNSA). The process begins with grid and R-tree filtering. First, the spatial bounding box 9 is computed. The space is then partitioned into 0 equal grids of size
1
Each cell maintains an R-tree of contained trajectories, and one center trajectory is selected per nonempty cell, producing the representative set 2.
GARI is then formed by computing 3 via DTSM for each pair 4. For each node 5, the other representative trajectories are sorted by similarity and partitioned into three buckets: 6, consisting of the top 7 most similar; 8, the next 9; and 0, the remaining 1 least similar. One neighbor is sampled from each bucket, and directed edges are added accordingly.
The lower layer, CNDI, is built through Comprehensive Node Fine-grained Integration (CNFI). For each trajectory 2 in the full database 3, the framework obtains 4 nearest neighbors 5 via R-tree lookup and uniformly samples 6 random trajectories 7. It computes 8 for all 9, sorts each set by similarity, and selects a fraction 0 from the close set and 1 from the random set as final neighbors.
The separation into an aggregated upper graph and a detailed lower graph gives the framework both coarse and fine search structure. A plausible implication is that the upper layer is intended to improve global entry-point quality, while the lower layer supports local refinement around promising regions of the trajectory space.
4. Online query answering
For a query trajectory 2 and top-3, the online phase proceeds in three stages: search on GARI, search on CNDI, and extraction of the final top-4 representative subtrajectories (Ge et al., 7 Jul 2025).
The search on GARI starts from a randomly selected node 5. The framework computes
6
For each neighbor 7 of 8, it computes 9. If any neighbor has a larger score than the current node, the search moves to
0
and repeats; otherwise it terminates at 1. The paper characterizes this hill-climbing process as a way to quickly find a globally representative trajectory.
The second stage starts from 2 and performs the same hill-climbing search in the lower graph CNDI. During this search, the framework maintains a visited set 3 containing all visited nodes and their scores. When no neighbor improves the current score, the process stops at 4.
The final stage uses the visited set 5. For each visited trajectory, the framework already has the representative subsegment and its score. It sorts these scores and returns the top 6 distinct trajectories’ subsegments.
This procedure differs from full-dataset scanning in that it restricts expensive similarity computation to graph neighborhoods explored during ascent. The reliance on a visited set rather than only the terminal node also indicates that the output is assembled from the local search trace rather than from a single endpoint.
5. Complexity characteristics
The indexing space complexity is
7
where 8 and 9 are neighbor counts per node.
For the offline phase, the reported costs are divided into three components. Grid and R-tree processing requires 0. GARI construction, dominated by pairwise DTSM computation over 1, requires 2. CNDI neighbor construction requires 3. The total offline time is therefore
4
For the online phase, each hill-climbing step visits 5 neighbors and invokes DTSM in 6. The number of steps is stated to be 7 in practice. Each of the two hill-climbing phases therefore costs
8
and the total online complexity is given as 9.
These expressions clarify the design trade-off. The framework expends substantial offline effort to construct graph structure and preselect neighborhoods, then amortizes that effort during query processing. This suggests a deployment model in which query latency is prioritized over index-construction cost.
6. Empirical evaluation and reported behavior
The reported experiments use two real datasets: Xi’an (DiDi GAIA), with 3.1 M trajectories from October 2016, and Chengdu (DiDi GAIA), with 5.8 M trajectories from November 2016 (Ge et al., 7 Jul 2025). After cleaning, the study samples 30 000 data trajectories and 2 000 query trajectories per city. Query lengths lie in 0, and data lengths lie in 1.
The baselines are OSF [10], described as subtrajectory filtering in Euclidean space; Grid, described as a simple uniform-cell spatial filter; LBF (RSSE) [14], described as a learning-based representative similarity estimator with filtering+validation; and the recent neural similarity models T3S [35] and TMN [37]. Evaluation uses Relative Rank (RR), where lower is better; Hit-Rate@2 (HR@k), where higher is better; and R10@50, defined as the overlap between actual top-10 and predicted top-50.
The paper reports that GTRSS+CMA, using CMA as internal subtrajectory search, is best in all settings of Table I under DTW, EDR, and ERP. Under DTW, the Xi’an / Chengdu results are reported as follows.
| Method | HR@20 | R10@50 |
|---|---|---|
| T3S | 0.0215/0.0257 | 0.0531/0.0618 |
| TMN | 0.1197/0.1022 | 0.2692/0.2286 |
| RSSE | 0.2398/0.3129 | 0.5076/0.5683 |
| GTRSS(CMA) | 0.9215/0.5482 | 0.9255/0.7770 |
| GTRSS(POS) | 0.6785/0.6295 | 0.6695/0.6202 |
| GTRSS(PSS) | 0.8333/0.8061 | 0.8510/0.8254 |
The same table also reports HR@50 values of 0.0569/0.0628 for T3S, 0.2279/0.1897 for TMN, 0.3727/0.4301 for RSSE, 0.8963/0.5939 for GTRSS(CMA), 0.6692/0.6195 for GTRSS(POS), and 0.7745/0.7563 for GTRSS(PSS). The summary states that similar patterns hold for EDR and ERP.
For efficiency, the per-query times under DTW+PSS on Xi’an / Chengdu are reported as Grid 3 s, OSF 4 s, LBF 5 s, GTRSS+ExactS 6 s, and GTRSS+(CMA/POS/PSS) 7 s. The paper further states that GTRSS+CMA answers a 2 kB query in 8 s, 1009 faster than prior state-of-the-art. In the abstract, the broader summary is that the method achieves retrieval accuracy of over 90 percent and up to two orders of magnitude speedup in query performance (Ge et al., 7 Jul 2025).
Scalability experiments vary the dataset size from 0.03 M to 0.8 M trajectories and report that GTRSS query time grows sublinearly, whereas OSF, Grid, and LBF scale linearly or worse. Ablation studies report that omitting the upper-layer GARI drops HR@50 by 40–50 points, removing random neighbors reduces HR by 15–20 points because search easily traps local optima, and recording all visited nodes improves final top-00 recall by 5–10 points. These ablations situate TRSSQ performance not only in the similarity metric but also in the interaction between graph topology, initialization, and search trace retention.