Abstract
In urban computing, road networks and trajectories represent the static infrastructure and dynamic flow of a city, respectively. Despite their intrinsic connection, most existing models treat them as separate entities, failing to capture their complex, many-to-many interactions. We present UniTR, a unified framework that jointly learns representations for both road networks and trajectories. By employing a hierarchical propagation mechanism and a triple-level contrastive loss, UniTR effectively captures static structural constraints and dynamic mobility patterns. Our evaluation on large-scale real-world datasets shows that UniTR significantly outperforms state-of-the-art baselines in tasks such as trajectory similarity search, road type classification, and traffic speed inference.
Introduction: The Skeleton and the Blood Flow
In urban environments, road networks (the "skeleton") and trajectories (the "blood flow") are two sides of the same coin. Road topology dictates where vehicles can travel, while trajectories reveal the actual importance and semantic usage of those roads. Understanding this relationship is crucial for intelligent transportation systems.
However, modeling this relationship presents two major hurdles. First, the interaction complexity is immense: a single trajectory traverses many road segments, and a single segment may be part of thousands of trajectories. Second, cross-scale optimization is difficult because road segments and entire trajectories exist at different spatial scales. Aligning their mathematical representations (embeddings) so they "speak the same language" is a non-trivial challenge that UniTR aims to solve.
Methodology
UniTR introduces a comprehensive four-stage pipeline designed to bridge the gap between static road data and dynamic mobility patterns.
1. Multi-Modal Input and Augmentation
Unlike models that rely solely on coordinates, UniTR incorporates visual context via Street View images processed through SwinTransformers. This allows the model to distinguish between different road environments (e.g., residential vs. highway) that might look identical in topological data. For data augmentation, UniTR uses mobility-aware strategies. Instead of random edge removal, it utilizes historical traffic data to calculate transition probabilities, selectively removing less significant edges to force the model to learn robust structural patterns.
2. Hierarchical Propagation
This core mechanism facilitates information flow across scales in three distinct steps:
- Road-to-Road: Uses Chebyshev graph convolutions to capture the local structural features of the road network.
- Road-to-Trajectory: Aggregates embeddings of road segments within a trajectory, combined with positional encodings, to form a cohesive trajectory representation.
- Trajectory-to-Road: Feeds trajectory information back into road segments. This allows segments to "learn" high-order mobility semantics—such as identifying major transit links—that are invisible from topology alone.
3. Triple-Level Contrastive Optimization
To refine the joint embeddings, UniTR employs a sophisticated contrastive learning strategy across three levels:
- Segment Level: Ensures that road segments with similar structural or visual characteristics have similar embeddings.
- Trajectory Level: Uses Jaccard similarity of paths to ensure trajectories following similar routes are grouped together in the embedding space.
- Cross Level: Acts as the "glue" that aligns the road and trajectory spaces by maximizing the similarity between a road segment and the trajectories that pass through it.
Experimental Evaluation
Datasets
The model was rigorously tested on two large-scale real-world datasets:
- Porto: A public dataset containing ~1.7 million trajectories and ~10,000 road segments.
- Chengdu: A private dataset from Didi Chuxing featuring ~5.8 million trajectories and ~6,700 road segments. Both datasets were augmented with road attributes from OpenStreetMap and panoramic street-view images from Google or Baidu Maps.
Key Results
UniTR consistently outperformed six state-of-the-art baselines (including Node2Vec and JCLRNT) across multiple downstream tasks:
- Trajectory Similarity Search: On the Porto dataset, UniTR achieved a Mean Rank (MR) of 1.740, a massive improvement over the best baseline, JCLRNT (MR 5.003).
- Road Type Classification: Achieved a Micro-F1 of 0.638 (Porto) and 0.668 (Chengdu), significantly higher than topology-only methods.
- Traffic Speed Inference: Reduced the Mean Absolute Error (MAE) to 2.10 in Porto, demonstrating that the joint embeddings effectively capture real-world traffic dynamics.
Conclusion and Future Work
UniTR demonstrates that treating trajectories as high-order features for road networks creates a powerful feedback loop for representation learning. While the model shows exceptional performance, future work will address the computational complexity of cross-level contrastive loss to scale the system for mega-cities. Additionally, exploring cross-city generalization—training on one city and testing on another—remains a promising frontier for creating truly universal urban mobility models.
Summary updated