Conceptio › Archive › arXiv CS
arXiv CS open access

Structure-Guided Spatiotemporal Attention Graph Neural Network for Traffic Flow Prediction

2026 · arxiv_cs
arXiv CS · Papers · 2026
Open Source ↗Direct PDF ↓
deep-learningmachine-learningneural-networks
Conceptio Open Archive

Analyze & explore related research in Conceptio

Connect this record directly into your research workflow or AI agent. Explore citations across open repositories, query full text, and export structured proof bundles.

1

Structure-Guided Spatiotemporal Attention Graph Neural Network for Traffic Flow Prediction

arXiv:2608.14177v1 [cs.LG] 14 Aug 2026

Xuanmian He, Can Li, Wanjing Ma

Abstract—Deep spatiotemporal models integrating graph convolutions and attention mechanisms have demonstrated excellent performance in network-level traffic flow prediction, owing to their exceptional ability to capture complex spatiotemporal dependencies. Despite their predictive success, deployment of such models in safety-critical urban systems remains constrained by their inherent lack of transparency. Existing post-hoc diagnostic methods often struggle with spurious correlations and fail to unveil the intrinsic decision-making mechanisms governing traffic dynamics, resulting in suboptimal interpretability and limited operational trustworthiness. To address these challenges, this paper proposes the Structure-Guided Spatiotemporal Attention Graph Neural Network (SGSAN). Departing from traditional architectures that rely on unconstrained adaptive graphs, SGSAN explicitly learns a static Directed Dependency Graph (DDG) to identify the invariant macroscopic propagation paths of traffic states. We further introduce an InfoNCE-based soft-coupling mechanism that anchors the model’s dynamic spatiotemporal attention to this structural prior, offering a mechanistic account of the model’s decision-making process while ensuring robust forecasting by aligning attention-based reasoning with identified macroscopic dependencies and preventing over-reliance on ephemeral local noise. Furthermore, a decoupled two-stage optimization framework is developed to resolve the fundamental conflict between structural discovery and predictive error minimization. Extensive experiments on multiple real-world datasets demonstrate that SGSAN achieves state-of-the-art predictive accuracy while providing built-in interpretability that organically aligns with the physical logic of traffic networks. Our findings highlight that explicitly modeling directed structural dependencies can transform opaque spatiotemporal correlations into transparent, mechanistic insights without sacrificing predictive performance. Index Terms—System state estimation, Data-based approaches, Traffic networks, Traffic Flow Prediction, Interpretability

I. Introduction Accurate and reliable spatiotemporal traffic flow prediction plays a vital role in Intelligent Transportation Systems (ITS), providing the analytical foundation for proactive traffic control, efficient congestion mitigation, and optimal route planning [1]. With the pervasive deployment of road network sensors, deep learning models have achieved high prediction accuracy by capturing complex features across large-scale networks [2]– [4]. However, the transition of these models from laboratory benchmarks to safety-critical urban systems is hindered by their "black-box" nature [5]. This research is supported by [52402407, the National Natural Science Foundation of China]. (Corresponding author: Can Li.) Xuanmian He is with the Department of Civil and Environmental Engineering, University of California, Berkeley, United States. Can Li is with the Key Laboratory of Road and Traffic Engineering of the Ministry of Education, Tongji University, Shanghai 201804, China (e-mail: xuanmianh@berkeley.edu, lican@tongji.edu.cn, mawanjing@tongji.edu.cn

In practical traffic engineering, achieving reliable results requires anchored predictions that supplement high accuracy with structural interpretability. The opacity of complex architectures often leads to the capture of spurious relations, where models may achieve low training error by over-fitting to ephemeral local noise rather than modeling the stable, underlying network structure [6]. To address this lack of transparency, an increasing number of studies have focused on developing interpretable frameworks. Existing efforts primarily fall into three categories: post-hoc diagnostics (such as LIME and SHAP [7], [8]) , gradient-based attribution methods [9], and attention-based mechanisms. While post-hoc methods can generate plausible rationalizations for predictions, they operate as external estimators that merely approximate model behavior without reflecting the actual internal decision-making mechanisms. Alternatively, although attention mechanisms provide a degree of transparency by highlighting important features [10], they are fundamentally correlation-driven [11]. In complex traffic environments, these unconstrained attention weights greedily aggregate a broad range of statistical signals to minimize immediate prediction error. This often includes spurious correlations, e.g., a sudden localized rainstorm might cause simultaneous congestion in two geographically disconnected zones. A purely data-driven predictive attention module will heavily rely on the strong statistical correlation despite the absence of a direct physical influence between zones. Consequently, the reasoning process remains loosely constrained and highly susceptible to noise, failing to provide the structural consistency required for engineering trust. While true interventionist causal inference is unachievable purely from observational traffic data without accounting for hidden confounders, the discovery techniques can be repurposed to learn a macroscopic structural prior [12]. In the context of traffic networks, dominant propagation paths are fundamentally dictated by the time-invariant macroscopic spatial topology. Incorporating such structural discovery into spatiotemporal learning enables the model to distinguish a stable global backbone from incidental local fluctuations or spurious correlations [13]. By anchoring dynamic reasoning to this learned backbone, the model moves beyond simple curvefitting, ensuring that its predictive logic remains consistent with the long-term dependency patterns of the road topology. Despite its potential, integrating structural priors with dynamic attention mechanisms faces a primary challenge: distilling a stable structural backbone from highly volatile traffic patterns without sacrificing the model’s sensitivity to real-time variations. This fundamental conflict stems from

2

two main issues. First, directly optimizing a graph structure alongside a deep predictive model often leads to gradient interference, where short-term prediction errors can distort the long-term dependency graph, resulting in an unstable topology [14]. Second, imposing rigid structural constraints can over-regularize the model, hindering its ability to respond to localized, non-topological events (e.g., accidents) [15]. To address this, we propose learning a static Directed Dependency Graph (DDG) to capture time-invariant global spatial dependencies, while retaining a spatiotemporal attention mechanism to adapt to dynamic local inputs. We adopt a twostage training framework that explicitly decouples structure learning (Stage I) from spatiotemporal correlation extraction (Stage II). This separation stabilizes the graph generation process and prevents disruption from local, short-term noise [16]. Furthermore, instead of imposing overly rigid constraints, we utilize InfoNCE contrastive learning as a form of soft regularization [17], [18]. By maximizing the mutual information between the multi-scale representations and the structural prior, this soft-coupling guides the attention mechanism to anchor onto the stable DDG while preserving the flexibility necessary to capture real-time, non-topological local variations. The main contributions of this study are summarized as follows: • We propose a structure-guided spatiotemporal architecture to overcome the reliance on unconstrained observational correlations and achieve a paradigm shift towards discovering time-invariant structural priors. Specifically, by learning a Directed Dependency Graph (DDG), our approach explicitly guides the attention-based prediction process to follow macroscopic propagation paths, mitigating the impact of spurious correlations and local noise. • We design the Structure-Guided Spatiotemporal Attention Graph Neural Network (SGSAN) to achieve structural stability and temporal flexibility while improving training and inference efficiency. Specifically, we employ a decoupled two-stage training strategy alongside a softcoupling mechanism that anchors dynamic attention to the static dependency graph, which has been shown to benefit convergence and prediction performance. • To evaluate the trustworthiness of the proposed framework, we introduce a new set of metrics that quantify the mechanistic alignment between model reasoning and physical network topology. Results demonstrate the alignment between learned dependency priors, attention maps, and physical road networks. Experiments on several realworld datasets demonstrate that SGSAN achieves stateof-the-art predictive accuracy while providing built-in interpretability. II. Related Works A. Interpretable Prediction Previous studies on interpretable prediction primarily fall into two categories [19]. 1) Inherently interpretable models, such as linear regression and ARIMA. Despite the clear physical implications, they often struggle to extract high-dimensional nonlinear

features and exhibit lower accuracy in complex traffic networks. 2) Approaches focusing on the explainability of “blackbox” models [20], including post-hoc diagnostic methods, physics-informed methods, attention-based methods, and causal analysis. Post-hoc diagnostic methods are frequently employed to illustrate prediction results. Cui et al. [21] visualized model representation weights in graph convolutional recurrent neural networks, analyzed the spatial features of traffic states, and provided explanations for specific results. Zhai et al. [22] introduced a post-hoc explainability measurement method for traffic prediction issues based on sensitivity and partial dependence graph correlation tests. Medrano et al. [23] employed SHAP, which establishes a dense layer after the traffic state prediction model to offer diagnostics for prediction results. Ribeiro et al. [7] compared and analyzed the global and local explanatory capabilities of diagnostic methods such as SHAP and LIME for travel time prediction. Although these methods are model-agnostic, their reliance on local approximations limits understanding of the neural network’s prediction logic and thus constrains the reliability of their explainability. The attention mechanism has been validated to identify the most important data features by allocating weights and considering contextual relevance, which enhances prediction accuracy [24]. It is particularly effective for modeling long-term dependencies in sequences. Furthermore, the attention weights contribute to a better understanding of the model, thereby increasing its interpretability. In the context of traffic flow prediction, these weights indicate the significance of various traffic flow features on the prediction outcomes within a specific traffic network structure [25]–[27]. Li et al. [28] introduced a dynamic spatiotemporal attention mechanism for traffic flow prediction, integrating it with classical traffic flow theory to analyze the speed of traffic wave propagation and to elucidate the correlations in traffic states. However, the explanations derived from the attention mechanism are often limited to specific samples, as the attention weights are closely tied to the features of the input data. Additionally, the mechanism primarily focuses on correlations, limiting its capacity to interpret the underlying causal mechanism of the predictions. B. From Causal Analysis to Structural Discovery Traditional neural networks can effectively identify correlations in data samples, but these correlations often lack interpretability and are susceptible to spurious statistical associations. In contrast, learning causal or structural relationships offers insights more aligned with the intrinsic mechanisms governing the prediction process. This distinction has motivated studies on causal and structure-aware modeling for traffic forecasting, which can be organized into two lines of work: causal discovery methods and causal-constrained spatiotemporal models. a) Pure Causal Discovery Methods: Early efforts to introduce causal reasoning into traffic modeling drew on classical techniques from the causal inference literature. Zhang et al. [29] conducted a nonlinear Granger causality analysis using a deep learning model for traffic speed prediction,

3

providing a principled criterion for selecting informative capture dynamic, local fluctuations. By softly coupling these features within the network and establishing that directional two mechanisms, SGSAN effectively mitigates the influence of temporal dependencies yield more stable representations than spurious correlations, yielding predictions that are both highly symmetric correlations. Concurrently, Yu et al. [30] proposed accurate and structurally interpretable. DAG-GNN, which integrates graph neural networks with variational autoencoders to learn implicit causal relationships III. Problem Formulation as a continuous directed acyclic graph optimization problem, A physical traffic network is mathematically defined as a offering a scalable alternative to combinatorial structure search. graph G = (V, E), where V is the set of 𝑉 detector nodes Building on this, Tygesen et al. [31] utilized inference graphs (|V | = 𝑉) and E is the set of edges representing the physical to reveal the model’s focus areas and to explain how spatial road connections. The underlying topological structure of this correlations are leveraged for traffic prediction, demonstrating network is represented by the physical adjacency matrix A ∈ that structural graph representations can meaningfully improve R𝑉 ×𝑉 . the interpretability of deep learning models. Let 𝑥 𝑡𝑖 ∈ R denote the traffic state (e.g., traffic flow) of node b) Causal-Constrained Spatiotemporal Models: Moti- 𝑖 at time step 𝑡. The collective traffic state of all nodes at vated by the limitations of purely data-driven attention mecha- time 𝑡 is denoted as X = [𝑥 1 , 𝑥 2 , · · · , 𝑥 𝑉 ] (X ∈ R𝑉 ). The 𝑡 𝑡 𝑡 𝑡 𝑡 nisms, recent works have incorporated explicit causal structures spatiotemporal traffic flow prediction problem aims to learn to mitigate spurious correlations in complex traffic networks. a mapping function 𝑓 (·) that leverages a historical sequence He et al. [32] introduced STGC-GNNs, which detect a Spatial- of traffic states over 𝑇 time steps, X 𝑉 ×𝑇 , alongside 𝑡 −𝑇+1:𝑡 ∈ R Temporal Granger Causality graph to replace static distance- the structural network information, to forecast the future traffic based dependencies, demonstrating that data-driven causality states over the next 𝐻 time steps, X 𝑉 ×𝐻 . 𝑡+1:𝑡+𝐻 ∈ R provides a more stable representation of underlying traffic This prediction task can be formally expressed as: flow dynamics. Zhao et al. [33] proposed a Causal CondiX̂𝑡+1:𝑡+𝐻 = 𝑓 (X𝑡 −𝑇+1:𝑡 , A) (1) tional Hidden Markov Model (CCHMM) that disentangles the physical concepts affecting multi-modal traffic generation In our proposed SGSAN framework, the function 𝑓 (·) operthrough a structural causal model, effectively isolating causal ates by explicitly learning a DDG, denoted as 𝐺 ∈ R𝑉 ×𝑉 , which representations from observational noise. Yang et al. [34] serves as a structural prior to guide a dynamic spatiotemporal further proposed the Principal Spatio-Temporal Causal Graph attention mechanism. A comprehensive summary of the key Convolutional Network (PSTCGCN), which employs causal notations used throughout this paper is provided in Table I. convolutions and semi-principal graph embeddings to capture spatio-temporal causal dependencies in a unified framework. TABLE I More recently, Zhu et al. [35] reinforced this paradigm by Summary of Key Notations integrating causal inference with graph convolutional networks Notation Definition to filter spurious edges and enhance model robustness against noisy observations. 𝑉 Number of detector nodes in the network 𝑇 Length of the historical input sequence Despite their contributions, existing methods either pursue 𝐻 Length of the prediction horizon strict causal identification, which is unachievable from ob𝑑 Dimension of the hidden representation layers servational traffic data alone without handling confounders 𝑁 Number of samples in a training batch X𝑡 Traffic states of all nodes at time step 𝑡 and interventional experiments [36], or focus on isolated local A Physical adjacency matrix of the road network (A ∈ R𝑉 ×𝑉 ) causal features without capturing the global, time-invariant 𝐺∗ Adjacency matrix of the learned DDG (𝐺 ∗ ∈ R𝑉 ×𝑉 ) propagation topology in the network. Rather than claiming 𝐺𝑎 Dynamic spatial attention weight matrix (𝐺 𝑎 ∈ R𝑉 ×𝑉 ) strict causal identification, SGSAN reframes the objective ℎ𝑛 Initial node embedding (ℎ 𝑛 ∈ R𝑉 ×𝑑 ) ℎ𝑡 Temporal attention representation (ℎ𝑡 ∈ R𝑉 ×𝑑 ) as structural dependency discovery. Different from diffusion𝑠𝑡𝑟 ℎ Structural representation derived from DDG (ℎ 𝑠𝑡𝑟 ∈ R𝑉 ×𝑑 ) based graph formulations that propagate traffic states along preℎ 𝑎𝑡𝑡 Spatiotemporal attention representation (ℎ 𝑎𝑡𝑡 ∈ R𝑉 ×𝑑 ) defined directional road structures [37], we apply the continuous optimization techniques of causal discovery to learn a DDG that reflects the dominant propagation topology of the network IV. Methodology without requiring interventional data. Critically, existing methods have not resolved the fundaIn order to effectively fuse static structural knowledge with mental tension between static global structural knowledge and dynamic real-time flexibility, we propose the Structure-Guided the dynamic, real-time flexibility required for accurate short- Spatiotemporal Attention Graph Neural Network (SGSAN), term prediction. While they have attempted to incorporate shown in Figure 1. It is a four-module architecture designed causal graphs into learning frameworks, they predominantly to bridge structural discovery with spatiotemporal modeling. employ rigid fusion strategies. Such hard fusion impedes the First, the embedding module employs a temporal attention submechanistic clarity of the causal structure and sacrifices the module to extract time-series features and project the historical dynamic flexibility required to capture non-topological traffic states into initial node embeddings. Operating in parallel, anomalies as well. To bridge this gap, SGSAN proposes a hybrid the spatiotemporal attention module and structural discovery paradigm. Structural discovery is employed to generate a global module are designed to extract spatiotemporal features at dependency graph and the spatiotemporal attention is used to distinct scales. The structural discovery module learns the

4

Fig. 1. Framework of Structure-Guided Spatiotemporal Attention Graph Neural Network (SGSAN)

DDG 𝐺 ∗ to capture stable and time-invariant dependencies node embeddings, enhanced by a graph convolution layer to among the nodes, and to identify the dominant dependency further capture spatial relationships within the network. Instead backbone, as detailed in Section IV-A. As detailed in Section of processing traffic flow directly, the module utilizes node IV-B, the spatiotemporal attention module stacks two spatial embeddings that are encoded through a temporal attention layer. attention layers and one temporal attention layer to generate the Each node embedding encapsulates the temporal dimension in dynamic hidden state ℎ 𝑎𝑡𝑡 . Specifically, 𝐺 𝑎 denotes the weight the form of sequence information, allowing its shape to remain map derived from the final spatial attention layer, encapsulating independent of the sequence length. The main aim of learning the data-driven local correlations. the dependency graph is to provide the attention module The decoder’s output is then convolved to produce structural with a stable structural prior. Mathematically, the dependency representations ℎ 𝑠𝑡𝑟 that capture these global topological graph is optimized as a directed acyclic graph (DAG) [36]. relationships. An inherent tension exists between these two Inspired by [30], we design a structural discovery module parallel tracks, i.e., the structural discovery module must that employs the DAG-GNN model, which is derived from filter out short-term spurious correlations to distill the high- structural equation models (SEM) and follows the architecture level global topology, whereas the spatiotemporal attention of variational autoencoders (VAE), consisting of an encoder module greedily captures localized temporal variations to and a decoder. This module represents structural relationships maximize short-term prediction accuracy. To reconcile these through generative graphical models, transforming the creation divergent objectives and fuse the multi-scale information, of the dependency graph into a continuous optimization we introduce a two-stage training framework equipped with problem. A linear SEM can be expressed as follows: InfoNCE contrastive learning. As detailed in Section IV-C, ℎ ← 𝐵𝑇 ℎ + 𝑍 (2) this soft-coupling mechanism resolves optimization conflicts by ensuring the dynamic attention is mechanically guided by where 𝐵 ∈ R𝑉 ×𝑉 represents the parameterized adjacency matrix the static structural prior. Finally, the output module utilizes of the graph. ℎ is the input, and 𝑍 is a noise matrix. Therefore, fully connected layers to generate the ultimate prediction. the mapping from the noise matrix to the original input is Depending on the specific phase of our two-stage framework, denoted as: this prediction head dynamically routes the representations from either the spatiotemporal module or the structural discovery ℎ = (I − 𝐵𝑇 ) −1 𝑍 (3) module to yield the final output. where I is the identity matrix. Based on this, the linear SEM can be transformed into a VAE structure: A. Structural Discovery Module ( The primary objective of the structural discovery module 𝑍 = 𝑀 𝐿𝑃[(I − 𝐺 𝑇 ) · 𝑀 𝐿𝑃(ℎ 𝑛 )] (4) is to construct a directed dependency graph and generate ℎˆ 𝑠𝑡𝑟 = 𝑀 𝐿𝑃[(I − 𝐺 𝑇 ) −1 · 𝑀 𝐿𝑃(𝑍)] a hidden structural representation (ℎ 𝑠𝑡𝑟 ), enabling StructureGuided attention. This module primarily consists of an encoderIn this framework, transformations are applied through multidecoder structure that extracts topological information from layer perceptrons (𝑀 𝐿𝑃). The encoder utilizes the node embed-

5

ding ℎ 𝑛 , while the decoder generates the intermediate output represent learnable parameter matrices. Finally, these scores are ℎˆ 𝑠𝑡𝑟 . The matrix 𝐺 represents the normalized dependency normalized with the Softmax function to produce the attention graph adjacency matrix that needs to be learned. weight matrix 𝐺 𝑎 = [𝑒 𝑖 𝑗 ]. Each element in 𝐺 𝑎 indicates the Following the VAE structure, a graph convolution layer is im- dynamic spatial correlation between node 𝑖 and node 𝑗. We plemented to produce the final structural representation. Graph capture the weight matrix from the last spatial attention subconvolution extracts spatial features by aggregating information module, denoted as the "attention map", which is subsequently from neighboring nodes. The mathematical formulation is as aligned with the structural representation ℎ 𝑠𝑡𝑟 to generate the final spatiotemporal representation ℎ 𝑎𝑡𝑡 . follows: 1 1 ℎ 𝑠𝑡𝑟 = 𝑅𝑒𝐿𝑈 ( 𝐷˜ − 2 𝐴˜ 𝐷˜ − 2 ℎˆ 𝑠𝑡𝑟 𝑊)

C. Loss Function To resolve the inherent optimization conflict between discovwhere ℎ 𝑠𝑡𝑟 denotes the structural representation, 𝐴˜ represents ering stable structural dependencies and minimizing dynamic the normalized physical adjacency matrix after adding self˜ 𝑊 denotes the prediction errors, we design a two-stage training framework. loops, and 𝐷˜ denotes the degree matrix of 𝐴. The overall objective function is composed of four components: learnable coefficient matrix. prediction loss (L 𝐴), dependency structural loss (L 𝐷 ), sparsity The initialization of the structural adjacency matrix 𝐵 aims regularizer (L 𝑆 ), and InfoNCE soft-coupling loss (L 𝐼 ). to improve the expression of nonlinear features. Starting from a (1) Prediction Loss (L 𝐴): We employ Mean Squared Error parameterized matrix 𝐵0 , the 𝑠𝑖𝑛ℎ(·) function is introduced to (MSE) to optimize the predictive accuracy of the model: amplify the significance of strong dependencies, modulated by 𝑁 a temperature coefficient 𝜏. To obtain the final adjacency matrix 1 ∑︁ 𝑖 L = ( 𝑦ˆ − 𝑦 𝑖𝑡 ) 2 (10) 𝐴 𝐺 used in Equation (4), we apply a Softmax normalization, 𝑁 𝑖=1 𝑡 thereby incorporating the weights of directed dependencies 𝑖 𝑖 into the model training process. The Softmax function assigns where 𝑦ˆ 𝑡 denotes the predicted traffic state, 𝑦 𝑡 is the ground the origin of influence for each node relative to others in the truth, and 𝑁 is the number of samples in the batch. (2) Dependency Structural Loss (L 𝐷 ): To ensure the network: 𝐺 = 𝑆𝑜 𝑓 𝑡𝑚𝑎𝑥(𝑠𝑖𝑛ℎ(𝜏 · 𝐵0 )) (6) learned dependency graph forms a valid directed acyclic structure, we enforce a continuous NOTEARS trace exponential penalty [39]: B. Spatiotemporal Attention Module L 𝐷 = 𝑐(𝑉) · [tr(𝑒 𝐺⊙𝐺 ) − 𝑉] (11) To effectively model temporal dynamics in sequential traffic flow states, the temporal attention sub-module utilizes a multi- where 𝐺 ∈ R𝑉 ×𝑉 is the adjacency matrix of the dependency head self-attention mechanism, comprising keys (𝐾), queries graph, 𝑉 is the number of nodes in the physical network, tr(·) (𝑄), and values (𝑉). They are generated through linear mapping represents the trace of a matrix, ⊙ denotes the Hadamard of the input ℎ𝑡 , reflecting the underlying high-dimensional product, and 𝑒 (·) denotes the matrix exponential. Based on characteristics of the data. The structural equation of the the properties of the matrix exponential, tr(𝑒 𝐺⊙𝐺 ) = 𝑉 holds attention module can be represented as follows: strictly true if and only if 𝐺 is an acyclic structure. The term 𝑐(𝑉) is a normalization coefficient set to 1 × 10− (𝑉//10) that 𝑇 𝑄𝑖 · 𝐾 𝑗 𝛼𝑖 𝑗 = Softmax( √ ) (7) can easily stabilize gradients across different graph scales. (3) Sparsity Regularizer (L 𝑆 ): To prevent over-smoothing 𝐷 in spatial aggregators and eliminate redundant edges, an 𝐿 1 ∑︁ ℎ𝑒𝑎𝑑 = 𝐴𝑡𝑡 (𝑄 𝑖 , 𝐾, 𝑉) = 𝛼𝑖 𝑗 𝑉 𝑗 (8) regularization term is applied: 𝑗

(5)

𝑉 ∑︁ 𝑉 ∑︁ L 𝑆 = ∥𝐺 ∥ 1 = |𝐺 𝑖 𝑗 | (12) where 𝛼𝑖 𝑗 represents the normalized attention weight coefficient. 𝑖=1 𝑗=1 𝐴𝑡𝑡 (·) is the weighted sum of coefficients multiplied by the value vector, incorporating temporal attention weights into the This strict structural sparsity serves as a crucial inductive prediction process. Assuming 𝑚 attention heads, the outputs bias, aiding the model in identifying the dominant dependency are concatenated along their respective dimensions and undergo backbone while reducing the influence of spurious correlations. (4) InfoNCE Soft-Coupling Loss (L 𝐼 ): Instead of dia linear mapping to produce the temporal attention-based rectly enforcing similarity via KL divergence—which often representation vector ℎ𝑡 . To capture the complex spatial dependencies in traffic leads to rigid structural constraints and eliminates temporal networks, we adopt a spatial attention module based on the flexibility—we utilize contrastive learning to enhance the graph attention network (GAT) [38]. For any node in the spatiotemporal attention mechanism [17]: graph, the attention score 𝑒 𝑖 𝑗 between its temporal attention 𝑁 exp(sim(ℎ𝑖𝑠𝑡𝑟 , ℎ𝑖𝑎𝑡𝑡 )/𝜏0 ) 1 ∑︁ representation ℎ𝑖𝑡 and ℎ𝑡𝑗 is calculated as: L𝐼 = − log Í 𝑁 (13) 𝑁 𝑖=1 exp(sim(ℎ𝑖𝑠𝑡𝑟 , ℎ 𝑎𝑡𝑡 )/𝜏0 ) 𝑗=1 𝑗 𝑒 𝑖 𝑗 = Softmax 𝑗 [𝐿𝑒𝑎𝑘 𝑦𝑅𝑒𝐿𝑈 ( [𝑊1 ℎ𝑖𝑡 ∥ 𝑊2 ℎ𝑡𝑗 ] · 𝑊3 )] (9) where ℎ𝑖𝑠𝑡𝑟 denotes the structural representation derived from where 𝑒 𝑖 𝑗 denotes the attention scores, and the symbol ∥ the dependency graph, and ℎ𝑖𝑎𝑡𝑡 denotes the dynamic spatiotemrepresents the vector concatenation operation. 𝑊1 , 𝑊2 , and 𝑊3 poral attention representation. sim(·) is the cosine similarity

6

function, and 𝜏0 is the temperature for InfoNCE loss. This coupling mechanism operates as a soft alignment strategy, effectively anchoring the attention to the dependency skeleton while preserving the necessary representational freedom for the attention mechanism to capture real-time local dependencies. D. Two-Stage Training Strategy Training the directed dependency structure and the attention mechanism simultaneously forces them to optimize fundamentally different objectives concurrently, leading to mutual interference and degraded performance. To address this, we introduce an explicitly decoupled two-stage learning process, outlined in Algorithm 1. Stage I (DDG Generation): The main objective is to learn a global dependency graph that incorporates timeinvariant macroscopic topology. The dynamic attention module is excluded, and the structural discovery module is optimized using the following joint loss: LStage-I = L 𝐴 + 𝛾 𝐷 · L 𝐷 + 𝛾𝑆 · L 𝑆

(14)

Stage II (Soft Alignment): The structural discovery module is frozen, providing the learned dependency graph (𝐺 ∗ ) as a stable structural prior. The spatiotemporal attention module is then activated and optimized. The core objective in this stage is to softly couple the multi-scale representations, mitigating spurious correlations while preserving the attention mechanism’s flexibility to adapt to real-time inputs. The total loss function is defined as: LStage-II = L 𝐴 + 𝛾 𝐼 · L 𝐼 (15)

Algorithm 1 Two-Stage Training Framework of SGSAN Input: Input sequences X𝑡 −𝑇+1:𝑡 , Adjacency matrix A, Balancing hyperparameters 𝛾 𝐷 , 𝛾𝑆 , 𝛾 𝐼 Output: Predicted traffic states X̂𝑡+1:𝑡+𝐻 1: Initialize parameters for Temporal Module M 𝑡 , Spatial Attention Module M 𝑠 , Structural Discovery Module M 𝑠𝑡𝑟 , and Output Module 𝑓𝑜𝑢𝑡 . 2: 3: Stage I: Generate the Directed Dependency Graph

(DDG) 4: while Stage I not converged do 5: ℎ𝑡 = M𝑡 (X𝑡 −𝑇+1:𝑡 ) 6: ℎ 𝑠𝑡𝑟 , 𝐺 = M 𝑠𝑡𝑟 (ℎ𝑡 , A) 7: X̂𝑡+1:𝑡+𝐻 = 𝑓𝑜𝑢𝑡 (ℎ 𝑠𝑡𝑟 ) 8: Compute LStage-I via Eq. (14) 9: Update M𝑡 , M 𝑠𝑡𝑟 , 𝑓𝑜𝑢𝑡 by minimizing LStage-I 10: end while 11: Extract and freeze the optimized DDG matrix 𝐺 ∗ 12: 13: Stage II: Soft Alignment of Spatiotemporal Attention 14: while Stage II not converged do 15: ℎ𝑡 = M𝑡 (X𝑡 −𝑇+1:𝑡 ) 16: ℎ 𝑎𝑡𝑡 = M 𝑠 (ℎ𝑡 , 𝐺 ∗ ) {Guided by the stable structural

prior} 17: X̂𝑡+1:𝑡+𝐻 = 𝑓𝑜𝑢𝑡 (ℎ 𝑎𝑡𝑡 ) 18: Compute LStage-II via Eq. (15) 19: Update M𝑡 , M 𝑠 , 𝑓𝑜𝑢𝑡 by minimizing LStage-II 20: end while

where 𝛾 𝐷 , 𝛾𝑆 , and 𝛾 𝐼 are balancing coefficients determined A. Datasets and Experiment Setup empirically to achieve an optimal balance between directed We adopt four open-source traffic datasets for evaluations, dependency graph convergence and contrastive learning. which are provided by the Performance Measurement SysThe training complexity of our model is reduced through tem (PeMS) of the California Department of Transportation: its decoupled design. In Stage I, generating the DDG involves PeMS03, PeMS07, PeMS08, and PeMS-Bay. Detailed descripcontinuous DAG optimization, which carries an 𝑂 (𝑁 3 ) com- tions of the datasets are provided in Table II. plexity. However, this functions strictly as an offline pre-training process. In Stage II, the standard spatial attention complexity of TABLE II Descriptive Analysis of Datasets 𝑂 (𝑇 · 𝑁 2 · 𝐷) is significantly reduced. By masking the attention map with the learned sparse dependency graph, the complexity Dataset PeMS03 PeMS07 PeMS08 PeMS-Bay drops to 𝑂 (𝑇 · |𝐸 | · 𝐷), where |𝐸 | is the number of retained 2 Timesteps 26,208 28,224 17,856 52,116 edges (|𝐸 | ≪ 𝑁 ). Number of nodes 358 883 170 325 During the validation and online testing stages, the structural Number of edges 549 865 276 2,369 discovery module is bypassed entirely. The future traffic states Predicted state Volume Volume Volume Mean Speed are predicted by feeding the dynamic inputs through the spatiotemporal attention module, which is guided purely by the The length of the input sequence is 15 minutes, and the frozen, pre-computed sparse DDG mask. Therefore, the online prediction horizon is set to 15, 30, and 60 minutes. The training, inference complexity remains strictly bounded at 𝑂 (𝑇 · |𝐸 | · 𝐷), validation, and test sets were split in a ratio of 7:1:2. The Adam bypassing the heavy structural generation overhead entirely. optimizer is adopted, and the learning rate is 4 × 10−4 with a dropout rate of 0.1. The model was trained on an NVIDIA V. Experiment and Results Tesla A800 GPU for 100 epochs, with the first 50 epochs for To validate our proposed model, we implement and train Stage I and 50 epochs for Stage II to balance training efficiency the model on several real-world traffic flow datasets, compare and the sufficiency of dependency structure learning. prediction results with baseline models, and conduct ablation Through hyperparameter tuning, we determined the optimal studies on the structural discovery module and the two-stage settings: the hidden layer dimension in our SGSAN model is learning framework. In addition, we compare the training set to 16 for every module, and each temporal attention module and inference efficiency of these models theoretically and has 4 heads. The values for 𝛾 𝐷 , 𝛾𝑆 and 𝛾 𝐼 in Equations (14) empirically. and (15) are 0.1, 1 × 10−6 , and 1 × 10−3 , respectively.

7

To validate the predictive performance of the interpretable model proposed in this paper, we conduct comparative experiments with other baseline models on the same dataset. To clarify, SGSAN (Ours) denotes the proposed model trained with the two-stage framework. • Temporal Graph Convolutional Network (T-GCN) [40]:

Combines GCNs for spatial topology with GRUs for temporal dynamics. • Spatio-Temporal Graph Convolutional Network (STGCN) [41]: Integrates 1D causal convolutions and graph convolutions without relying on RNNs. • Graph Multi-Attention Network (GMAN) [42]: Employs multiple spatial and temporal attention mechanisms with a transform attention layer. • Attention-based Spatiotemporal Graph Convolutional Network (ASTGCN) [43]: Incorporates spatial and temporal attention mechanisms within a GCN framework. • Spatiotemporal Transformer Network (STTN) [44]: Dynamically models dependencies utilizing self-attention mechanisms across spatial and temporal domains. • Dynamic Spatial-Temporal Trend Transformer (DST2former) [45]: Captures spatio-temporal correlations through adaptive embedding and fuses dynamic trends with static graph attributes via Cross Spatial-Temporal Attention. • Dual Cross-Scale Transformer (DCST) [46]: Utilizes a dual-path architecture to capture dependencies across micro and macro temporal scales. • Causal Conditional Hidden Markov Model (CCHMM) [33]: Employs mutually supervised prior and posterior networks to disentangle causal representations of physical concepts in multimodal traffic. • Principal Spatio-Temporal Causal Graph Convolutional Network (PSTCGCN) [34]: Leverages causal discovery algorithms to generate a causal graph prior for spatiotemporal forecasting.

B. Comparative Analysis of Prediction Accuracy As shown in Table III, the proposed SGSAN (Ours) method achieves state-of-the-art predictive accuracy on all four datasets. Compared to models with Transformer structures, such as STTN, DST2Former, and DCST, SGSAN (Ours) outperforms them, especially when the prediction horizon is not so long. An interesting phenomenon is that these models with more complicated structures fail to demonstrate their high capacity when the prediction horizon is 15 minutes. Nevertheless, when the prediction horizon increases, the advantages of capturing long sequence dependency are fully realized. For the proposed model SGSAN (Ours), the structural discovery module corrects the potential spurious correlations introduced by unconstrained attention and finds sparser and more global feature significance, further improving the prediction accuracy. This highlights that the Structure-Guided spatiotemporal attention mechanism demonstrates a strong capacity for prediction by identifying the dominant propagation paths and interpreting the built-in mechanism of traffic flow dynamics.

C. Ablation Studies The ablation studies examine the effectiveness of the DDG and the two-stage training framework. Table IV shows the prediction accuracy in the ablation studies, where baseline models used for comparison are • STA-GNN (Spatiotemporal Attention-based Graph Neural Network) – The structural discovery module has been entirely removed, and the prediction results are only derived from the attention module. • SGSAN (DAG-Relaxed): The model architecture and twostage training framework remain identical to the proposed SGSAN. We introduce a tolerance margin 𝜖 = 0.1 into the dependency structural loss L 𝐷 to relax the strict acyclicity constraint. This can address the concern that strict DAG assumption may over-constrain the structural learning process. • SGSAN (Random-DDG): The model architecture and twostage training framework remain identical to the proposed SGSAN. However, rather than employing the DDG G ∗ learned through the structural discovery module in Stage I, we substitute it with a randomly generated sparse DAG G rand of equivalent edge density, whose non-zero entries are drawn from a uniform distribution and subsequently normalized. • SGSAN (Joint) – A single-stage joint training framework. The architecture is the same as the proposed model but trained end-to-end simultaneously with all losses active. The comprehensive ablation results presented in Table IV demonstrate the advantages of the proposed SGSAN and validate the contributions of its individual components and the two-stage training framework. Compared to the proposed two-stage framework, SGSAN (Joint) struggles to converge on complex networks. For example, its MAE on PeMS07 at the 60-min horizon increased sharply to 70.26. This indicates that simultaneously learning macroscopic priors and local correlations leads to severe optimization conflicts, a bottleneck our decoupled framework effectively resolves. To rule out that improvements stem solely from sparsity penalties, we evaluate SGSAN (Random-DDG). Applying a random sparse prior without structural guidance sometimes leads to worse performance than the unconstrained STAGNN (e.g., PeMS07 at the 15-min horizon). Furthermore, the degradation of SGSAN (DAG-Relaxed) shows that relaxing strict acyclic constraints introduces spurious cyclic noise. The marked advantage of SGSAN (Ours) over these baselines validates that our framework successfully captures genuine macroscopic dependencies. Among coupling mechanisms, InfoNCE outperforms MSE, cosine, and KL divergence in many cases. Hard constraints force the dynamic attention matrix to rigidly replicate the static DDG, restricting its capability to adapt to real-time, nontopological local fluctuations. In contrast, InfoNCE anchors the attention mechanism without forcing absolute equality, granting the numerical freedom to capture dynamic local variances. Admittedly, strict numerical regularization provides tight bounds under specific conditions, occasionally giving alternative metrics a slight edge. However, InfoNCE still holds the advantage across MAE, MAPE, and RMSE in general.

8

TABLE III Performance Comparison: Prediction Accuracy Horizon=15min MAE MAPE RMSE

Horizon=30min MAE MAPE RMSE

Horizon=60min MAE MAPE RMSE

MAE

Average MAPE

RMSE

PeMS03

T-GCN STGCN GMAN ASTGCN STTN DST2Former DCST CCHMM PSTCGCN SGSAN (Ours)

20.18 17.05 14.87 14.40 16.43 16.53 16.24 23.16 16.40 13.74

19.13 14.41 13.37 12.26 17.38 16.25 13.89 19.85 13.50 11.06

27.82 26.76 23.15 25.17 24.20 25.65 26.17 35.37 24.59 22.56

29.02 26.96 23.65 23.98 22.40 20.41 19.13 33.96 19.46 18.62

26.65 25.99 20.35 20.68 19.12 16.54 17.02 31.04 15.96 15.13

43.36 39.58 36.70 37.71 34.14 32.13 34.19 50.03 29.69 30.71

36.42 31.72 32.00 24.07 27.38 24.72 31.26 28.19 21.53 22.98

33.86 29.73 28.79 20.25 31.77 21.96 28.68 27.87 17.35 18.79

53.03 46.78 47.63 37.65 42.68 37.82 46.41 41.12 33.25 36.74

28.54 25.24 23.51 20.81 22.07 20.55 22.21 28.44 19.13 18.45

26.55 23.38 20.83 17.73 22.75 18.25 19.86 26.26 15.60 14.99

41.40 37.71 35.83 33.51 33.67 31.87 35.59 42.17 29.18 30.00

PeMS07

T-GCN STGCN GMAN ASTGCN STTN DST2Former DCST CCHMM PSTCGCN SGSAN (Ours)

33.66 29.91 26.02 23.29 23.29 24.92 24.34 34.76 26.30 22.84

15.50 12.73 11.47 10.31 11.02 10.94 9.91 15.46 15.99 9.31

47.55 44.41 38.51 35.64 35.47 36.50 36.25 49.87 37.39 35.11

38.72 36.78 34.37 31.42 36.30 29.34 27.99 41.29 31.28 27.47

18.41 16.11 16.64 13.26 16.77 12.37 11.51 20.46 18.46 11.05

54.38 53.62 49.35 46.78 49.95 42.15 41.12 57.58 44.27 40.95

53.37 47.04 47.11 37.41 43.24 38.58 35.78 48.90 40.14 33.89

28.05 23.15 24.90 17.07 19.30 18.82 14.62 22.49 24.50 14.75

73.81 65.69 65.07 53.37 57.50 52.99 51.14 68.31 56.08 50.02

41.91 37.91 35.83 30.71 34.28 30.94 29.37 41.65 32.57 28.07

20.65 17.33 17.67 13.55 15.70 14.05 12.01 19.47 19.65 11.70

58.58 54.57 50.97 45.26 47.64 43.88 42.83 58.59 45.91 42.02

PeMS08

T-GCN STGCN GMAN ASTGCN STTN DST2Former DCST CCHMM PSTCGCN SGSAN (Ours)

21.19 21.35 15.32 15.31 16.41 17.91 16.97 26.80 18.43 14.71

11.76 10.01 9.47 9.13 10.82 9.31 9.78 16.51 13.67 8.59

30.74 30.45 26.55 23.83 23.17 25.89 25.65 39.91 26.70 22.04

28.94 25.75 25.76 22.48 24.11 21.02 21.15 30.69 21.89 20.58

19.17 15.25 16.45 13.08 19.74 12.56 12.77 20.33 15.83 11.74

41.52 37.60 37.16 33.74 33.90 31.50 32.67 44.49 31.72 31.25

44.07 34.06 34.52 29.00 28.11 26.05 25.95 35.67 27.65 24.91

30.77 21.71 22.29 17.19 15.53 16.04 15.75 23.52 19.91 14.60

61.81 47.53 48.46 42.73 40.51 37.19 40.26 49.72 39.66 37.18

31.40 27.05 25.20 22.26 22.88 21.66 21.36 31.05 27.65 20.06

20.56 15.66 16.07 13.13 15.36 12.64 12.77 20.12 19.91 11.64

44.69 38.53 37.39 33.43 32.53 31.52 32.86 44.71 39.66 30.15

PeMS-Bay

T-GCN STGCN GMAN ASTGCN STTN DST2Former DCST CCHMM PSTCGCN SGSAN (Ours)

1.82 1.78 1.63 1.54 1.64 1.54 1.50 1.66 1.93 1.48

3.74 3.49 3.41 3.19 3.39 3.30 3.19 3.43 4.80 3.01

3.40 3.08 3.22 3.18 3.18 2.97 3.01 3.23 4.26 2.70

2.42 2.60 2.20 2.10 2.26 2.17 1.99 2.26 2.45 1.99

5.28 5.66 4.89 4.61 4.64 4.34 4.27 5.05 5.96 4.30

4.71 4.91 4.56 4.42 4.20 3.94 3.99 4.53 5.15 3.87

3.00 3.33 2.95 2.77 2.82 2.61 2.39 3.13 2.95 2.38

6.87 7.53 6.95 6.10 6.17 5.47 5.23 7.31 7.38 5.17

5.74 6.11 6.02 5.81 5.11 5.18 4.76 6.02 6.17 4.60

2.41 2.57 2.26 2.14 2.24 2.11 1.96 2.35 2.45 1.95

5.30 5.56 5.08 4.63 4.73 4.37 4.23 5.26 6.05 4.16

4.62 4.70 4.60 4.47 4.16 4.03 3.92 4.59 5.19 3.73

Dataset

Model

D. Computational Efficiency In terms of computational efficiency, the proposed two-stage framework excels in both the training and deployment phases. We evaluate its performance from two perspectives: training speed and online inference latency. 1) Training Efficiency: As shown in Table V, this twostage decoupled approach SGSAN (Ours) reduces the average training time per epoch by approximately 31.7% across all datasets compared to the joint-learning baseline SGSAN (Joint), effectively mitigating the computational bottleneck of simultaneous graph generation and prediction. 2) Inference Efficiency: For real-world urban computing deployments, inference efficiency is a crucial performance metric. Because our global dependency graph is statically learned offline, it introduces zero structural generation overhead during the online inference phase. The online data flow is comparable to standard GNNs, requiring only the application of the pre-learned sparse graph mask. Table VI compares the average inference time per sample on the PeMS03 dataset. SGSAN (Ours) achieves a low latency of

0.096 ms/sample. Notably, it is vastly more efficient than the recent causal baseline PSTCGCN, which relies on heavier online dependency structure generation. While ASTGCN and CCHMM are marginally faster, our framework offers a significantly superior trade-off by achieving much higher predictive accuracy, making it highly suitable for real-time, safety-critical traffic management systems. Additionally, the proposed SGSAN (Ours) is considerably faster than the baseline SGSAN (Joint). E. Interpretability Analysis To comprehensively demonstrate that SGSAN provides trustworthy and interpretable prediction, we conduct both qualitative and quantitative analyses on its interpretability. We evaluate internal consistency to show that the dynamic attention is properly anchored to the learned structural backbone, and we evaluate external physical alignment to verify that the learned components naturally reflect the real-world road network topology. Additionally, we examine dynamic flexibility to

9

TABLE IV Prediction Results in the Ablation Studies Horizon=15min MAE MAPE RMSE

Horizon=30min MAE MAPE RMSE

Horizon=60min MAE MAPE RMSE

PeMS03

STA-GNN SGSAN (DAG-Relaxed) SGSAN (Random-DDG) SGSAN (Joint) SGSAN (Ours) - KL SGSAN (Ours) - Cosine SGSAN (Ours) - MSE SGSAN (Ours) - InfoNCE

17.70 16.30 16.45 14.05 15.80 15.57 16.75 13.74

14.42 18.36 17.76 11.20 13.35 12.03 12.88 11.06

28.88 30.40 26.30 22.95 24.85 23.57 22.67 22.56

21.30 20.74 23.28 25.59 20.23 19.91 22.09 18.62

17.02 22.95 26.86 23.59 16.12 16.82 17.92 15.13

34.54 33.52 33.10 38.60 32.02 31.98 31.79 30.71

28.36 24.15 25.47 31.72 24.26 24.22 24.35 22.98

23.07 22.71 26.42 32.36 20.90 19.78 26.94 18.79

44.46 37.60 39.07 44.87 37.08 37.02 36.23 36.74

PeMS07

STA-GNN SGSAN (DAG-Relaxed) SGSAN (Random-DDG) SGSAN (Joint) SGSAN (Ours) - KL SGSAN (Ours) - Cosine SGSAN (Ours) - MSE SGSAN (Ours) - InfoNCE

25.52 28.87 27.46 25.06 28.36 24.56 28.40 22.84

11.65 14.38 15.21 11.35 11.70 13.61 11.50 9.31

37.73 39.23 38.34 37.20 38.39 34.67 38.62 35.11

32.65 30.86 30.81 58.93 30.79 30.89 31.46 27.47

14.51 18.51 17.71 29.93 14.54 15.22 14.29 11.05

47.61 42.89 42.29 77.35 44.04 42.31 42.61 40.95

42.16 36.16 34.33 70.26 34.99 35.76 33.57 33.89

19.32 16.30 18.74 36.53 17.97 17.93 16.49 14.75

60.06 53.73 53.52 89.04 52.25 52.18 51.39 50.02

PeMS08

STA-GNN SGSAN (DAG-Relaxed) SGSAN (Random-DDG) SGSAN (Joint) SGSAN (Ours) - KL SGSAN (Ours) - Cosine SGSAN (Ours) - MSE SGSAN (Ours) - InfoNCE

18.55 16.32 19.92 15.75 15.92 15.33 15.44 14.71

10.64 9.54 10.42 9.78 9.50 9.19 9.28 8.59

28.15 25.89 27.31 23.13 23.79 22.93 23.12 22.04

22.26 23.31 24.28 24.92 22.37 22.37 22.41 20.58

12.56 16.66 17.84 14.62 12.34 13.14 12.49 11.74

33.78 32.25 32.96 37.53 32.06 33.14 32.07 31.25

30.22 26.70 25.92 26.51 25.96 26.23 25.78 24.91

17.49 18.89 18.46 16.19 18.05 17.12 18.66 14.60

43.82 39.59 41.25 39.34 38.89 38.11 38.49 37.18

PeMS-Bay

STA-GNN SGSAN (DAG-Relaxed) SGSAN (Random-DDG) SGSAN (Joint) SGSAN (Ours) - KL SGSAN (Ours) - Cosine SGSAN (Ours) - MSE SGSAN (Ours) - InfoNCE

1.51 1.62 1.61 2.49 1.62 1.62 1.55 1.48

3.08 3.59 3.47 3.75 3.56 3.55 3.28 3.01

3.11 3.07 3.01 3.84 3.05 3.04 2.87 2.70

2.07 2.03 2.02 3.30 2.00 2.00 1.99 1.99

4.59 4.46 4.47 6.54 4.46 4.43 4.36 4.30

4.40 3.92 3.93 5.65 3.91 3.90 3.89 3.87

2.83 2.42 2.39 3.86 2.37 2.37 2.37 2.38

6.74 5.34 5.34 7.02 5.34 5.39 5.28 5.17

5.89 4.66 4.63 5.30 4.66 4.68 4.64 4.60

Dataset

Model

Fig. 2. Sensitivity Analysis of Interpretability Metrics (ASC, SPC, and APC) across varying sparsity levels (Top-𝐾%)

TABLE V Average Training Time Per Epoch Model

PeMS03

PeMS07

PeMS08

PeMS-Bay

SGSAN (Joint) SGSAN (Ours)

11.35s 8.35s

52.21s 31.73s

4.63s 3.25s

21.20s 14.57s

Reduction

-26.4%

-39.2%

-29.8%

-31.3%

ensure the model adaptively balances global structural reliance with local stochasticity.

1) Consistency Metrics for Structure-Guided Interpretability: To quantitatively validate the structure-guided mechanisms of SGSAN, we evaluate the alignment between the structural dependency prior and the dynamic spatiotemporal attention. A foundational assumption of our framework is that a truly interpretable and trustworthy model should implicitly capture the physical macroscopic backbone of the road network, rather than relying on spurious statistical noise. (i) Attention-Structural Consistency (ASC). This metric measures the internal alignment between the static DDG and the dynamic spatiotemporal attention map. The rationale is that

10

(a) Example 1

(b) Example 2

(c) Example 3

(d) Example 4

(e) Example 5

(f) Example 6

Fig. 3. Example Nodes in the Subgraphs illustrating consistency between the DDG and the Attention Map.

(ii) Structural-Physical Consistency (SPC) and AttentionPhysical Consistency (APC). While ASC measures internal alignment, there is a risk that the metric is self-referential, as Model Avg Time per Sample (ms) Stage II explicitly integrates the dependency graph and attention T-GCN 0.044 ± 0.003 maps. To provide an external evaluation, we introduce SPC ASTGCN 0.078 ± 0.001 and APC. SPC measures the overlap between the learned DDG CCHMM 0.079 ± 0.004 SGSAN (Ours) 0.096 ± 0.003 and the actual physical road network adjacency matrix, while DCST 0.125 ± 0.001 APC measures the overlap between the dynamic attention map STCGCN 0.136 ± 0.002 and the physical network. DST2Former 0.155 ± 0.002 PSTCGCN 0.434 ± 0.008 2) Quantitative Analysis of Structural Consistency: This SGSAN (Joint) 0.511 ± 0.005 section presents the quantitative results of interpretability using STTN 0.513 ± 0.001 the metrics introduced in Section V-E1. Figure 2 presents a sensitivity analysis of these metrics across a trustworthy model should anchor its attention weights to the varying sparsity levels (from Top-10% to Top-50% retained underlying structural backbone identified in Stage I. A high capacity) for all four datasets. The results yield three crucial ASC indicates the effectiveness of the InfoNCE contrastive insights regarding the model’s interpretability. learning loss. First, the high SPC scores across datasets demonstrate that our learned dependency graph organically aligns with the physical topology, successfully capturing the true macroscopic 𝐵 1 ∑︁ 1 𝐴𝑆𝐶 = |{TopK(𝐺 𝑎 (𝑏))} ∩ {TopK(𝐺 ∗ )}| (16) structure of the traffic network without any geographic super𝐵 𝑏=1 𝐾 vision. Moreover, the APC and SPC curves exhibit closely matched where TopK(·) denotes the operation of selecting the top 𝐾% of node pairs with the highest weight values. 𝐺 𝑎 (𝑏) denotes values and parallel trajectories across all sparsity levels (e.g., at the attention map associated with batch 𝑏, and 𝐵 denotes the the Top-30% threshold on PeMS-Bay, SPC and APC reach 0.88 total number of batches. While the dependency graph (𝐺 ∗ ) and 0.85, respectively). This proves that the dynamic attention remains static, the attention map dynamically adapts to real- mechanism faithfully inherits the physical alignment of the time inputs in each batch. A higher 𝐴𝑆𝐶 value indicates a structural prior. stronger structural prior guiding the attention mechanism. Finally, the ASC metric proves highly robust across varying TABLE VI Inference Efficiency Comparison

11

network densities. The InfoNCE coupling effectively anchors formance. In terms of computational efficiency, SGSAN the attention to the core structural skeleton while retaining the (Ours) outperforms most baselines in inference efficiency, numerical freedom required for the attention mechanism to while the two-stage training framework enhances the training capture real-time, non-topological dependencies. efficiency. Furthermore, through newly introduced structural 3) Visualization of Graph Alignment: This section offers a consistency metrics, we verify that the model provides built-in qualitative analysis of the model’s interpretability, highlighting interpretability. The learned DDG achieves an 88% alignment the visual alignment between the structural dependencies with the physical structure of real networks, without relying and the attention mechanism. We utilize the sample-specific on any geographic constraints. By shifting the focus from attention map 𝐺 𝑎 along with the static dependency graph unconstrained statistical correlations to directed structural 𝐺 ∗ to identify and filter significant node pairs, creating "key dependencies, this work provides a trustworthy, highly accurate, subgraphs" for visualization. While the dependency graph and deployable modeling framework for transportation systems. remains uniform across all inputs, the attention map varies dynamically. For this visualization, we average the attention Acknowledgment weights across the test set and juxtapose them with the This research was supported by [2024YFB4303100, National dependency graph. The edges in the key subgraphs represent Key R&D Program of China] and [52402407, the National the most significant node-to-node dependencies. Figure 3 demonstrates the relationship dynamics for six Natural Science Foundation of China]. typical nodes. A strong consistency between the directed dependencies and the attention-based correlations is evident, References with the width of each arrow indicating the weight of the [1] E. I. Vlahogianni, M. G. Karlaftis, and J. C. Golias, “Short-term traffic relationship. forecasting: Where we are and where we’re going,” Transportation Research Part C-Emerging Technologies, vol. 43, pp. 3–19, 2014. A key observation is that while the dependency graph is [2] X. Yin, G. Wu, J. Wei, Y. Shen, H. Qi, and B. Yin, “Deep learning sparser and highly focused, the majority of the dominant paths on traffic prediction: Methods, analysis, and future directions,” IEEE it identifies are faithfully mirrored in the attention map. Because Transactions on Intelligent Transportation Systems, vol. 23, no. 6, pp. 4927–4943, 2021. the dependency graph learns from the macroscopic structure [3] Y. Lv, Y. Duan, W. Kang, Z. Li, and F.-Y. Wang, “Traffic flow prediction of the entire dataset, it provides the model with a global with big data: A deep learning approach,” IEEE Transactions on perspective to identify the true propagation paths of traffic Intelligent Transportation Systems, vol. 16, no. 2, pp. 865–873, 2015. [4] Y. X. Tian and L. Pan, “Predicting short-term traffic flow by long flow. short-term memory recurrent neural network,” 2015 Ieee International When comparing this Structure-Guided attention map with Conference on Smart City/Socialcom/Sustaincom (Smartcity), pp. 153– the baseline STA-GNN, a critical difference emerges. Without 158, 2015. structural constraints, standard attention weights tend to be sym- [5] C. X. Wang, Y. X. Liang, and G. R. Tan, “wcitycan: Causal attention network for citywide spatio-temporal forecasting,” Proceedings of the metric and undirected, often producing bidirectional arrows that 17th Acm International Conference on Web Search and Data Mining, merely reflect statistical correlation rather than physical influWsdm 2024, pp. 702–711, 2024. [6] Y. Zhang, P. Tino, A. Leonardis, and K. Tang, “A survey on neural ence. In contrast, because our dependency graph is constrained network interpretability,” Ieee Transactions on Emerging Topics in to be directed and acyclic, the Structure-Guided attention map Computational Intelligence, vol. 5, no. 5, pp. 726–742, 2021. adopts these asymmetric relationships. Bidirectional arrows [7] M. T. Ribeiro, S. Singh, and C. Guestrin, “"why should i trust you?": Explaining the predictions of any classifier,” ACM, 2016. rarely appear, demonstrating that the InfoNCE contrastive [8] S. M. Lundberg and S.-I. Lee, “A unified approach to interpreting model learning successfully transfers the directional logic of the predictions,” Advances in neural information processing systems, vol. 30, physical network into the attention mechanism. SGSAN aligns 2017. its prediction process with the actual physical features governing [9] S. Bach, A. Binder, G. Montavon, F. Klauschen, K.-R. Müller, and W. Samek, “On pixel-wise explanations for non-linear classifier decisions traffic state propagation, thereby making it trustworthy and by layer-wise relevance propagation,” PloS one, vol. 10, no. 7, p. robust. e0130140, 2015. VI. Conclusion In this paper, we proposed the Structure-Guided Spatiotemporal Attention Graph Neural Network (SGSAN) to bridge the gap between high-accuracy deep learning and trustworthy traffic flow prediction. Traditional attention mechanisms are fundamentally driven by observational correlations, making them susceptible to local noise and spurious correlations. To address this limitation, our framework explicitly decouples structural discovery from representation learning via a twostage training strategy. By learning a time-invariant Directed Dependency Graph (DDG) and employing an InfoNCE-based soft-coupling mechanism, SGSAN successfully anchors dynamic spatiotemporal attention to a stable structural prior. Extensive experiments on four real-world datasets demonstrate that SGSAN achieves state-of-the-art predictive per-

[10] L. N. N. Do, H. L. Vu, B. Q. Vo, Z. Y. Liu, and D. Phung, “An effective spatial-temporal attention based neural network for traffic flow prediction,” Transportation Research Part C-Emerging Technologies, vol. 108, pp. 12–28, 2019. [11] S. Wiegreffe and Y. Pinter, “Attention is not not explanation,” in Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing and the 9th International Joint Conference on Natural Language Processing (EMNLP-IJCNLP), K. Inui, J. Jiang, V. Ng, and X. Wan, Eds. Hong Kong, China: Association for Computational Linguistics, Nov. 2019, pp. 11–20. [12] D. Janzing, “Causal regularization,” Advances in Neural Information Processing Systems 32 (Nips 2019), vol. 32, 2019. [13] W. J. Murdoch, C. Singh, K. Kumbier, R. Abbasi-Asl, and B. Yu, “Definitions, methods, and applications in interpretable machine learning,” Proceedings of the National Academy of Sciences, vol. 116, no. 44, pp. 22 071–22 080, 2019. [14] L. Franceschi, M. Niepert, M. Pontil, and X. He, “Learning discrete structures for graph neural networks,” in International conference on machine learning. PMLR, 2019, pp. 1972–1982. [15] W. Jiang and J. Luo, “Graph neural network for traffic forecasting: A survey,” Expert systems with applications, vol. 207, p. 117921, 2022.

12

[16] W. Jin, Y. Ma, X. Liu, X. Tang, S. Wang, and J. Tang, “Graph structure learning for robust graph neural networks,” in Proceedings of the 26th ACM SIGKDD international conference on knowledge discovery & data mining, 2020, pp. 66–74. [17] A. van den Oord, Y. Li, and O. Vinyals, “Representation Learning with Contrastive Predictive Coding,” arXiv e-prints, p. arXiv:1807.03748, Jul. 2018. [18] Q. Zhang, C. Huang, L. Xia, Z. Wang, Z. Li, and S. Yiu, “Automated spatio-temporal graph contrastive learning,” in Proceedings of the ACM web conference 2023, 2023, pp. 295–305. [19] A. B. Arrieta, N. Díaz-Rodríguez, J. Del Ser, A. Bennetot, S. Tabik, A. Barbado, S. García, S. Gil-López, D. Molina, R. Benjamins, R. Chatila, and F. Herrera, “Explainable artificial intelligence (xai): Concepts, taxonomies, opportunities and challenges toward responsible ai,” Information Fusion, vol. 58, pp. 82–115, 2020. [20] Y. Liang, S. G. Li, C. G. Yan, M. Z. Li, and C. J. Jiang, “Explaining the black-box model: A survey of local interpretation methods for deep neural networks,” Neurocomputing, vol. 419, pp. 168–182, 2021. [21] Z. Y. Cui, K. Henrickson, R. M. Ke, and Y. H. Wang, “Traffic graph convolutional recurrent neural network: A deep learning framework for network-scale traffic learning and forecasting,” Ieee Transactions on Intelligent Transportation Systems, vol. 21, no. 11, pp. 4883–4894, 2020. [22] X. Zhai, F. Guo, and A. Sivakumar, “A novel interpretability evaluation framework to understand deep learning traffic prediction models,” SSRN Electronic Journal, 2022. [23] R. de Medrano and J. L. Aznarte, “A spatio-temporal attention-based spot-forecasting framework for urban traffic prediction,” Applied Soft Computing, vol. 96, 2020. [24] Z. Y. Niu, G. Q. Zhong, and H. Yu, “A review on the attention mechanism of deep learning,” Neurocomputing, vol. 452, pp. 48–62, 2021. [25] S. Y. Lan, Y. T. Ma, W. K. Huang, W. W. Wang, H. Y. Yang, and P. Y. Li, “Dstagnn: Dynamic spatial-temporal aware graph neural network for traffic flow forecasting,” International Conference on Machine Learning, Vol 162, 2022. [26] J. D. Bai, J. W. Zhu, Y. J. Song, L. Zhao, Z. X. Hou, R. H. Du, and H. F. Li, “A3t-gcn: Attention temporal graph convolutional network for traffic forecasting,” Isprs International Journal of Geo-Information, vol. 10, no. 7, 2021. [27] A. Ali, Y. M. Zhu, and M. Zakarya, “Exploiting dynamic spatio-temporal correlations for citywide traffic flow prediction using attention based neural networks,” Information Sciences, vol. 577, pp. 852–870, 2021. [28] G. P. Li, V. L. Knoop, and H. van Lint, “Multistep traffic forecasting by dynamic graph convolution: Interpretations of real-time spatial correlations,” Transportation Research Part C-Emerging Technologies, vol. 128, 2021. [29] K. P. Zhang, L. Zheng, Z. J. Liu, and N. Jia, “A deep learning based multitask model for network-wide traffic speed prediction,” Neurocomputing, vol. 396, pp. 438–450, 2020. [30] Y. Yu, J. Chen, T. Gao, and M. Yu, “DAG-GNN: DAG structure learning with graph neural networks,” in Proceedings of the 36th International Conference on Machine Learning, ser. Proceedings of Machine Learning Research, K. Chaudhuri and R. Salakhutdinov, Eds., vol. 97. PMLR, 09–15 Jun 2019, pp. 7154–7163. [31] M. N. Tygesen, F. C. Pereira, and F. Rodrigues, “Unboxing the graph: Towards interpretable graph neural networks for transport prediction through neural relational inference,” Transportation Research Part CEmerging Technologies, vol. 146, 2023. [32] S. He, Q. Luo, R. Du, L. Zhao, G. He, H. Fu, and H. Li, “Stgc-gnns: A gnn-based traffic prediction framework with a spatial–temporal granger causality graph,” Physica A: Statistical Mechanics and its Applications, vol. 623, p. 128913, 2023. [33] Y. Zhao, P. Deng, J. Liu, X. Jia, and M. Wang, “Causal conditional hidden markov model for multimodal traffic prediction,” in Proceedings of the AAAI Conference on Artificial Intelligence, 2023. [34] S. Yang, Q. Wu, Z. Li, and K. Wang, “Pstcgcn: Principal spatio-temporal causal graph convolutional network for traffic flow prediction,” Neural Computing and Applications, pp. 1–14, 2024. [35] J. Zhu, J. Yuan, T.-T. Nguyen, R. Wang, and W. Zeng, “Traffic prediction using an active causality recurrent graph convolutional network,” Expert Systems with Applications, p. 129506, 2025. [36] J. Pearl, Causality: models, reasoning, and inference. USA: Cambridge University Press, 2000. [37] X. Zhang, C. Huang, Y. Xu, L. Xia, P. Dai, L. Bo, J. Zhang, and Y. Zheng, “Traffic flow forecasting with spatial-temporal graph diffusion network,” in Proceedings of the AAAI conference on artificial intelligence, vol. 35, no. 17, 2021, pp. 15 008–15 015.

[38] P. Velickovic, G. Cucurull, A. Casanova, A. Romero, P. Lio, Y. Bengio et al., “Graph attention networks,” stat, vol. 1050, no. 20, pp. 10–48 550, 2017. [39] X. Zheng, B. Aragam, P. K. Ravikumar, and E. P. Xing, “Dags with no tears: Continuous optimization for structure learning,” in Advances in Neural Information Processing Systems, S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett, Eds., vol. 31. Curran Associates, Inc., 2018. [40] L. Zhao, Y. J. Song, C. Zhang, Y. Liu, P. Wang, T. Lin, M. Deng, and H. F. Li, “T-gcn: A temporal graph convolutional network for traffic prediction,” Ieee Transactions on Intelligent Transportation Systems, vol. 21, no. 9, pp. 3848–3858, 2020. [41] B. Yu, H. Yin, and Z. Zhu, “Spatio-temporal graph convolutional networks: A deep learning framework for traffic forecasting,” in Proceedings of the 27th International Joint Conference on Artificial Intelligence (IJCAI), 2018, pp. 3634–3640. [42] C. Zheng, X. Fan, C. Wang, and J. Qi, “Gman: A graph multi-attention network for traffic prediction,” in Proceedings of the AAAI conference on artificial intelligence, vol. 34, no. 01, 2020, pp. 1234–1241. [43] S. N. Guo, Y. F. Lin, N. Feng, C. Song, and H. Y. Wan, “Attention based spatial-temporal graph convolutional networks for traffic flow forecasting,” Thirty-Third Aaai Conference on Artificial Intelligence / Thirty-First Innovative Applications of Artificial Intelligence Conference / Ninth Aaai Symposium on Educational Advances in Artificial Intelligence, pp. 922–929, 2019. [44] C. L. Chen, Y. B. Liu, L. Chen, and C. Q. Zhang, “Bidirectional spatialtemporal adaptive transformer for urban traffic flow forecasting,” Ieee Transactions on Neural Networks and Learning Systems, vol. 34, no. 10, pp. 6913–6925, 2023. [45] J. Chen, H. Ye, Z. Ying, Y. Sun, and W. Xu, “Dynamic trend fusion module for traffic flow prediction,” Applied Soft Computing, vol. 174, p. 112979, 2025. [46] Y. Zhou, P. Wang, H. Dong, D. Zhang, D. Yang, Y. Fu, and P. Wang, “Make graph neural networks great again: a generic integration paradigm of topology-free patterns for traffic speed prediction,” in Proceedings of the Thirty-Third International Joint Conference on Artificial Intelligence, ser. IJCAI ’24, 2024. Xuanmian He is currently pursuing a master’s degree in Transportation Engineering at University of California, Berkeley. He received the bachelor’s degree in Traffic Engineering from Tongji University in 2025. His research interests include the intersection of artificial intelligence with traffic flow modeling and control, connected and automated vehicles, as well as trustworthy and interpretable decision-making in transportation.

Can Li Can Li received the M.S. degree in the Department of Electrical and Computer Engineering from Rutgers University and PhD degree in the School of Computer Science and Engineering from the University of New South Wales. She is currently an Associate Professor in the college of Transportation at Tongji University. Her research focuses on urban big data analytics, deep learning modeling, and transportation foundation models.

Wanjing Ma received the B.S. degree in architecture engineering from Chang’an University, Xi’an, China, in 2001, and the M.S. and Ph.D. degrees in traffic information engineering and control from Tongji University, Shanghai, China, in 2004 and 2007, respectively. He is currently a Professor with the College of Transportation, Tongji University. He has published more than 100 articles in Transportation Research Part B: Methodological and other domestic or foreign core journals and academic conferences. His research interests include traffic and control, vehicle-road coordination, and shared mobility.

Related documents

Record · ID 458304 · SHA-256 29471440b25e0395
Retrieved via Conceptio: every document is proof-bundled with source, license, and retrieval metadata.
Bring this data into your agent: Connect via MCP or API · 20 free credits to start · no card required
Read the Docs → · View CLI source on GitHub · Conceptio Open Knowledge Archive