Paper deep dive
Structure-Guided Spatiotemporal Attention Graph Neural Network for Traffic Flow Prediction
Xuanmian He, Can Li, Wanjing Ma
Intelligence
Status: succeeded | Model: Gemma-4-26B-A4B | Prompt: intel-v1 | Confidence: 92%
Last extracted: 8/17/2026, 5:16:13 AM
Summary
The paper proposes the Structure-Guided Spatiotemporal Attention Graph Neural Network (SGSAN) for traffic flow prediction. It addresses the lack of interpretability in deep learning models by learning a static Directed Dependency Graph (DDG) to capture invariant macroscopic propagation paths. An InfoNCE-based soft-coupling mechanism anchors dynamic spatiotemporal attention to this structural prior, while a decoupled two-stage optimization framework resolves conflicts between structural discovery and predictive error minimization. The model achieves state-of-the-art accuracy and built-in interpretability aligned with physical traffic network logic.
Entities (6)
Relation Signals (5)
SGSAN → solves → Traffic Flow Prediction
confidence 98% · Extensive experiments on multiple real-world datasets demonstrate that SGSAN achieves state-of-the-art predictive accuracy
SGSAN → uses → Directed Dependency Graph
confidence 95% · SGSAN explicitly learns a static Directed Dependency Graph (DDG) to identify the invariant macroscopic propagation paths of traffic states.
SGSAN → employs → InfoNCE
confidence 92% · We further introduce an InfoNCE-based soft-coupling mechanism that anchors the model’s dynamic spatiotemporal attention to this structural prior
National Natural Science Foundation of China → funded → SGSAN
confidence 90% · This research is supported by [52402407, the National Natural Science Foundation of China].
DAG-GNN → inspires → SGSAN
confidence 85% · Inspired by [35], we design a structural discovery module that employs the DAG-GNN model
Cypher Suggestions (0)
No Cypher suggestions yet.
Abstract
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.
Tags
Links
- Source: https://arxiv.org/abs/2608.14177v1
- Canonical: https://arxiv.org/abs/2608.14177v1
Trouble viewing inline? Open PDF directly →
Full Text
70,427 characters extracted from source content.
Expand or collapse full text
Structure-Guided Spatiotemporal Attention Graph Neural Network for Traffic Flow Prediction Xuanmian He Can Li Wanjing Ma Thanks: This research is supported by [52402407, the National Natural Science Foundation of China]. (Corresponding author: Can Li.) Thanks: 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 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 [29]. With the pervasive deployment of road network sensors, deep learning models have achieved high prediction accuracy by capturing complex features across large-scale networks [33, 20, 25]. However, the transition of these models from laboratory benchmarks to safety-critical urban systems is hindered by their "black-box" nature [30]. 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 [40]. 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 [24, 19]) , gradient-based attribution methods [3], 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 [9], they are fundamentally correlation-driven [31]. 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 [13]. 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 [21]. By anchoring dynamic reasoning to this learned backbone, the model moves beyond simple curve-fitting, 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 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 [10]. Second, imposing rigid structural constraints can over-regularize the model, hindering its ability to respond to localized, non-topological events (e.g., accidents) [14]. 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 two-stage training framework that explicitly decouples structure learning (Stage I) from spatiotemporal correlation extraction (Stage I). This separation stabilizes the graph generation process and prevents disruption from local, short-term noise [15]. Furthermore, instead of imposing overly rigid constraints, we utilize InfoNCE contrastive learning as a form of soft regularization [27, 38]. 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 soft-coupling 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 real-world datasets demonstrate that SGSAN achieves state-of-the-art predictive accuracy while providing built-in interpretability. I Related Works I-A Interpretable Prediction Previous studies on interpretable prediction primarily fall into two categories [2]. 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 “black-box” models [18], 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. [7] 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. [36] introduced a post-hoc explainability measurement method for traffic prediction issues based on sensitivity and partial dependence graph correlation tests. Medrano et al. [8] employed SHAP, which establishes a dense layer after the traffic state prediction model to offer diagnostics for prediction results. Ribeiro et al. [24] 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 [22]. 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 [16, 4, 1]. Li et al. [17] 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. I-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. 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. [37] conducted a nonlinear Granger causality analysis using a deep learning model for traffic speed prediction, providing a principled criterion for selecting informative features within the network and establishing that directional temporal dependencies yield more stable representations than symmetric correlations. Concurrently, Yu et al. [35] proposed DAG-GNN, which integrates graph neural networks with variational autoencoders to learn implicit causal relationships as a continuous directed acyclic graph optimization problem, offering a scalable alternative to combinatorial structure search. Building on this, Tygesen et al. [26] utilized inference graphs to reveal the model’s focus areas and to explain how spatial correlations are leveraged for traffic prediction, demonstrating that structural graph representations can meaningfully improve the interpretability of deep learning models. Causal-Constrained Spatiotemporal Models Motivated by the limitations of purely data-driven attention mechanisms, recent works have incorporated explicit causal structures to mitigate spurious correlations in complex traffic networks. He et al. [12] introduced STGC-GNNs, which detect a Spatial-Temporal Granger Causality graph to replace static distance-based dependencies, demonstrating that data-driven causality provides a more stable representation of underlying traffic flow dynamics. Zhao et al. [42] proposed a Causal Conditional Hidden Markov Model (CCHMM) that disentangles the physical concepts affecting multi-modal traffic generation through a structural causal model, effectively isolating causal representations from observational noise. Yang et al. [32] further proposed the Principal Spatio-Temporal Causal Graph Convolutional Network (PSTCGCN), which employs causal convolutions and semi-principal graph embeddings to capture spatio-temporal causal dependencies in a unified framework. More recently, Zhu et al. [46] reinforced this paradigm by integrating causal inference with graph convolutional networks to filter spurious edges and enhance model robustness against noisy observations. Despite their contributions, existing methods either pursue strict causal identification, which is unachievable from observational traffic data alone without handling confounders and interventional experiments [23], or focus on isolated local causal features without capturing the global, time-invariant propagation topology in the network. Rather than claiming strict causal identification, SGSAN reframes the objective as structural dependency discovery. Different from diffusion-based graph formulations that propagate traffic states along pre-defined directional road structures [39], we apply the continuous optimization techniques of causal discovery to learn a DDG that reflects the dominant propagation topology of the network without requiring interventional data. Critically, existing methods have not resolved the fundamental tension between static global structural knowledge and the dynamic, real-time flexibility required for accurate short-term prediction. While they have attempted to incorporate causal graphs into learning frameworks, they predominantly employ rigid fusion strategies. Such hard fusion impedes the mechanistic clarity of the causal structure and sacrifices the dynamic flexibility required to capture non-topological traffic anomalies as well. To bridge this gap, SGSAN proposes a hybrid paradigm. Structural discovery is employed to generate a global dependency graph and the spatiotemporal attention is used to capture dynamic, local fluctuations. By softly coupling these two mechanisms, SGSAN effectively mitigates the influence of spurious correlations, yielding predictions that are both highly accurate and structurally interpretable. I Problem Formulation A physical traffic network is mathematically defined as a graph =(,ℰ)G=(V,E), where V is the set of V detector nodes (||=V|V|=V) and ℰE is the set of edges representing the physical road connections. The underlying topological structure of this network is represented by the physical adjacency matrix ∈ℝV×VA ^V× V. Let xti∈ℝx^i_t denote the traffic state (e.g., traffic flow) of node i at time step t. The collective traffic state of all nodes at time t is denoted as t=[xt1,xt2,⋯,xtV](t∈ℝV)X_t=[x^1_t,x^2_t,·s,x^V_t](X_t ^V). The spatiotemporal traffic flow prediction problem aims to learn a mapping function f(⋅)f(·) that leverages a historical sequence of traffic states over T time steps, t−T+1:t∈ℝV×TX_t-T+1:t ^V× T, alongside the structural network information, to forecast the future traffic states over the next H time steps, t+1:t+H∈ℝV×HX_t+1:t+H ^V× H. This prediction task can be formally expressed as: ^t+1:t+H=f(t−T+1:t,) X_t+1:t+H=f(X_t-T+1:t,A) (1) In our proposed SGSAN framework, the function f(⋅)f(·) operates by explicitly learning a DDG, denoted as G∈ℝV×VG ^V× V, which serves as a structural prior to guide a dynamic spatiotemporal attention mechanism. A comprehensive summary of the key notations used throughout this paper is provided in Table I. TABLE I: Summary of Key Notations Notation Definition V Number of detector nodes in the network T Length of the historical input sequence H Length of the prediction horizon d Dimension of the hidden representation layers N Number of samples in a training batch tX_t Traffic states of all nodes at time step t A Physical adjacency matrix of the road network (∈ℝV×VA ^V× V) G∗G^* Adjacency matrix of the learned DDG (G∗∈ℝV×VG^* ^V× V) GaG^a Dynamic spatial attention weight matrix (Ga∈ℝV×VG^a ^V× V) hnh^n Initial node embedding (hn∈ℝV×dh^n ^V× d) hth^t Temporal attention representation (ht∈ℝV×dh^t ^V× d) hstrh^str Structural representation derived from DDG (hstr∈ℝV×dh^str ^V× d) hatth^att Spatiotemporal attention representation (hatt∈ℝV×dh^att ^V× d) IV Methodology Fig. 1: Framework of Structure-Guided Spatiotemporal Attention Graph Neural Network (SGSAN) In order to effectively fuse static structural knowledge with dynamic real-time flexibility, we propose the Structure-Guided Spatiotemporal Attention Graph Neural Network (SGSAN), shown in Figure 1. It is a four-module architecture designed to bridge structural discovery with spatiotemporal modeling. First, the embedding module employs a temporal attention sub-module to extract time-series features and project the historical states into initial node embeddings. Operating in parallel, the spatiotemporal attention module and structural discovery module are designed to extract spatiotemporal features at distinct scales. The structural discovery module learns the DDG G∗G^* to capture stable and time-invariant dependencies among the nodes, and to identify the dominant dependency backbone, as detailed in Section IV-A. As detailed in Section IV-B, the spatiotemporal attention module stacks two spatial attention layers and one temporal attention layer to generate the dynamic hidden state hatth^att. Specifically, GaG^a denotes the weight map derived from the final spatial attention layer, encapsulating the data-driven local correlations. The decoder’s output is then convolved to produce structural representations hstrh^str that capture these global topological relationships. An inherent tension exists between these two parallel tracks, i.e., the structural discovery module must filter out short-term spurious correlations to distill the high-level global topology, whereas the spatiotemporal attention module greedily captures localized temporal variations to maximize short-term prediction accuracy. To reconcile these divergent objectives and fuse the multi-scale information, we introduce a two-stage training framework equipped with InfoNCE contrastive learning. As detailed in Section IV-C, this soft-coupling mechanism resolves optimization conflicts by ensuring the dynamic attention is mechanically guided by the static structural prior. Finally, the output module utilizes fully connected layers to generate the ultimate prediction. Depending on the specific phase of our two-stage framework, this prediction head dynamically routes the representations from either the spatiotemporal module or the structural discovery module to yield the final output. IV-A Structural Discovery Module The primary objective of the structural discovery module is to construct a directed dependency graph and generate a hidden structural representation (hstrh^str), enabling Structure-Guided attention. This module primarily consists of an encoder-decoder structure that extracts topological information from node embeddings, enhanced by a graph convolution layer to further capture spatial relationships within the network. Instead of processing traffic flow directly, the module utilizes node embeddings that are encoded through a temporal attention layer. Each node embedding encapsulates the temporal dimension in the form of sequence information, allowing its shape to remain independent of the sequence length. The main aim of learning the dependency graph is to provide the attention module with a stable structural prior. Mathematically, the dependency graph is optimized as a directed acyclic graph (DAG) [23]. Inspired by [35], we design a structural discovery module that employs the DAG-GNN model, which is derived from structural equation models (SEM) and follows the architecture of variational autoencoders (VAE), consisting of an encoder and a decoder. This module represents structural relationships through generative graphical models, transforming the creation of the dependency graph into a continuous optimization problem. A linear SEM can be expressed as follows: h←BTh+Zh← B^Th+Z (2) where B∈ℝV×VB ^V× V represents the parameterized adjacency matrix of the graph. h is the input, and Z is a noise matrix. Therefore, the mapping from the noise matrix to the original input is denoted as: h=(−BT)−1Zh=(I-B^T)^-1Z (3) where I is the identity matrix. Based on this, the linear SEM can be transformed into a VAE structure: Z=MLP[(−GT)⋅MLP(hn)]h^str=MLP[(−GT)−1⋅MLP(Z)] casesZ=MLP[(I-G^T)· MLP(h^n)]\\ h^str=MLP[(I-G^T)^-1· MLP(Z)] cases (4) In this framework, transformations are applied through multi-layer perceptrons (MLPMLP). The encoder utilizes the node embedding hnh^n, while the decoder generates the intermediate output h^str h^str. The matrix G represents the normalized dependency graph adjacency matrix that needs to be learned. Following the VAE structure, a graph convolution layer is implemented to produce the final structural representation. Graph convolution extracts spatial features by aggregating information from neighboring nodes. The mathematical formulation is as follows: hstr=ReLU(D~−12A~D~−12h^strW)h^str=ReLU( D^- 12 A D^- 12 h^strW) (5) where hstrh^str denotes the structural representation, A~ A represents the normalized physical adjacency matrix after adding self-loops, and D~ D denotes the degree matrix of A~ A. W denotes the learnable coefficient matrix. The initialization of the structural adjacency matrix B aims to improve the expression of nonlinear features. Starting from a parameterized matrix B0B_0, the sinh(⋅)sinh(·) function is introduced to amplify the significance of strong dependencies, modulated by a temperature coefficient τ. To obtain the final adjacency matrix G used in Equation (4), we apply a Softmax normalization, thereby incorporating the weights of directed dependencies into the model training process. The Softmax function assigns the origin of influence for each node relative to others in the network: G=Softmax(sinh(τ⋅B0))G=Softmax(sinh(τ· B_0)) (6) IV-B Spatiotemporal Attention Module To effectively model temporal dynamics in sequential traffic flow states, the temporal attention sub-module utilizes a multi-head self-attention mechanism, comprising keys (K), queries (Q), and values (V). They are generated through linear mapping of the input hth^t, reflecting the underlying high-dimensional characteristics of the data. The structural equation of the attention module can be represented as follows: αij=Softmax(Qi⋅KjTD) _ij=Softmax( Q_i·K_j^T D) (7) head=Att(Qi,K,V)=∑jαijVjhead=Att(Q_i,K,V)= _j _ijV_j (8) where αij _ij represents the normalized attention weight coefficient. Att(⋅)Att(·) is the weighted sum of coefficients multiplied by the value vector, incorporating temporal attention weights into the prediction process. Assuming m attention heads, the outputs are concatenated along their respective dimensions and undergo a linear mapping to produce the temporal attention-based representation vector hth^t. To capture the complex spatial dependencies in traffic networks, we adopt a spatial attention module based on the graph attention network (GAT) [28]. For any node in the graph, the attention score eije_ij between its temporal attention representation hith^t_i and hjth^t_j is calculated as: eij=Softmaxj[LeakyReLU([W1hit∥W2hjt]⋅W3)]e_ij=Softmax_j[LeakyReLU([W_1h^t_i W_2h^t_j]· W_3)] (9) where eije_ij denotes the attention scores, and the symbol ∥ represents the vector concatenation operation. W1W_1, W2W_2, and W3W_3 represent learnable parameter matrices. Finally, these scores are normalized with the Softmax function to produce the attention weight matrix Ga=[eij]G^a=[e_ij]. Each element in GaG^a indicates the dynamic spatial correlation between node i and node j. We capture the weight matrix from the last spatial attention sub-module, denoted as the "attention map", which is subsequently aligned with the structural representation hstrh^str to generate the final spatiotemporal representation hatth^att. IV-C Loss Function To resolve the inherent optimization conflict between discovering stable structural dependencies and minimizing dynamic prediction errors, we design a two-stage training framework. The overall objective function is composed of four components: prediction loss (ℒAL_A), dependency structural loss (ℒDL_D), sparsity regularizer (ℒSL_S), and InfoNCE soft-coupling loss (ℒIL_I). (1) Prediction Loss (ℒAL_A): We employ Mean Squared Error (MSE) to optimize the predictive accuracy of the model: ℒA=1N∑i=1N(y^ti−yti)2L_A= 1N _i=1^N( y_t^i-y_t^i)^2 (10) where y^ti y_t^i denotes the predicted traffic state, ytiy_t^i is the ground truth, and N is the number of samples in the batch. (2) Dependency Structural Loss (ℒDL_D): To ensure the learned dependency graph forms a valid directed acyclic structure, we enforce a continuous NOTEARS trace exponential penalty [44]: ℒD=c(V)⋅[tr(eG⊙G)−V]L_D=c(V)·[tr(e^G G)-V] (11) where G∈ℝV×VG ^V× V is the adjacency matrix of the dependency graph, V is the number of nodes in the physical network, tr(⋅)tr(·) represents the trace of a matrix, ⊙ denotes the Hadamard product, and e(⋅)e^(·) denotes the matrix exponential. Based on the properties of the matrix exponential, tr(eG⊙G)=Vtr(e^G G)=V holds strictly true if and only if G is an acyclic structure. The term c(V)c(V) is a normalization coefficient set to 1×10−(V//10)1× 10^-(V//10) that can easily stabilize gradients across different graph scales. (3) Sparsity Regularizer (ℒSL_S): To prevent over-smoothing in spatial aggregators and eliminate redundant edges, an L1L_1 regularization term is applied: ℒS=‖G‖1=∑i=1V∑j=1V|Gij|L_S=\|G\|_1= _i=1^V _j=1^V|G_ij| (12) This strict structural sparsity serves as a crucial inductive bias, aiding the model in identifying the dominant dependency backbone while reducing the influence of spurious correlations. (4) InfoNCE Soft-Coupling Loss (ℒIL_I): Instead of directly enforcing similarity via KL divergence—which often leads to rigid structural constraints and eliminates temporal flexibility—we utilize contrastive learning to enhance the spatiotemporal attention mechanism [27]: ℒI=−1N∑i=1Nlogexp(sim(histr,hiatt)/τ0)∑j=1Nexp(sim(histr,hjatt)/τ0)L_I=- 1N _i=1^N (sim(h_i^str,h_i^att)/ _0) _j=1^N (sim(h_i^str,h_j^att)/ _0) (13) where histrh_i^str denotes the structural representation derived from the dependency graph, and hiatth_i^att denotes the dynamic spatiotemporal attention representation. sim(⋅)sim(·) is the cosine similarity function, and τ0 _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. IV-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 time-invariant macroscopic topology. The dynamic attention module is excluded, and the structural discovery module is optimized using the following joint loss: ℒStage-I=ℒA+γD⋅ℒD+γS⋅ℒSL_Stage-I=L_A+ _D·L_D+ _S·L_S (14) Stage I (Soft Alignment): The structural discovery module is frozen, providing the learned dependency graph (G∗G^*) 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: ℒStage-I=ℒA+γI⋅ℒIL_Stage-I=L_A+ _I·L_I (15) where γD _D, γS _S, and γI _I are balancing coefficients determined empirically to achieve an optimal balance between directed dependency graph convergence and contrastive learning. Algorithm 1 Two-Stage Training Framework of SGSAN 0: Input sequences t−T+1:tX_t-T+1:t, Adjacency matrix A, Balancing hyperparameters γD,γS,γI _D, _S, _I 0: Predicted traffic states ^t+1:t+H X_t+1:t+H 1: Initialize parameters for Temporal Module ℳtM_t, Spatial Attention Module ℳsM_s, Structural Discovery Module ℳstrM_str, and Output Module foutf_out. 2: 3: Stage I: Generate the Directed Dependency Graph (DDG) 4: while Stage I not converged do 5: ht=ℳt(t−T+1:t)h^t=M_t(X_t-T+1:t) 6: hstr,G=ℳstr(ht,)h^str,G=M_str(h^t,A) 7: ^t+1:t+H=fout(hstr) X_t+1:t+H=f_out(h^str) 8: Compute ℒStage-IL_Stage-I via Eq. (14) 9: Update ℳt,ℳstr,foutM_t,M_str,f_out by minimizing ℒStage-IL_Stage-I 10: end while 11: Extract and freeze the optimized DDG matrix G∗G^* 12: 13: Stage I: Soft Alignment of Spatiotemporal Attention 14: while Stage I not converged do 15: ht=ℳt(t−T+1:t)h^t=M_t(X_t-T+1:t) 16: hatt=ℳs(ht,G∗)h^att=M_s(h^t,G^*) Guided by the stable structural prior 17: ^t+1:t+H=fout(hatt) X_t+1:t+H=f_out(h^att) 18: Compute ℒStage-IL_Stage-I via Eq. (15) 19: Update ℳt,ℳs,foutM_t,M_s,f_out by minimizing ℒStage-IL_Stage-I 20: end while The training complexity of our model is reduced through its decoupled design. In Stage I, generating the DDG involves continuous DAG optimization, which carries an O(N3)O(N^3) complexity. However, this functions strictly as an offline pre-training process. In Stage I, the standard spatial attention complexity of O(T⋅N2⋅D)O(T· N^2· D) is significantly reduced. By masking the attention map with the learned sparse dependency graph, the complexity drops to O(T⋅|E|⋅D)O(T·|E|· D), where |E||E| is the number of retained edges (|E|≪N2|E| N^2). During the validation and online testing stages, the structural discovery module is bypassed entirely. The future traffic states are predicted by feeding the dynamic inputs through the spatiotemporal attention module, which is guided purely by the frozen, pre-computed sparse DDG mask. Therefore, the online inference complexity remains strictly bounded at O(T⋅|E|⋅D)O(T·|E|· D), bypassing the heavy structural generation overhead entirely. V Experiment and Results To validate our proposed model, we implement and train the model on several real-world traffic flow datasets, compare prediction results with baseline models, and conduct ablation studies on the structural discovery module and the two-stage learning framework. In addition, we compare the training and inference efficiency of these models theoretically and empirically. V-A Datasets and Experiment Setup We adopt four open-source traffic datasets for evaluations, which are provided by the Performance Measurement System (PeMS) of the California Department of Transportation: PeMS03, PeMS07, PeMS08, and PeMS-Bay. Detailed descriptions of the datasets are provided in Table I. TABLE I: Descriptive Analysis of Datasets Dataset PeMS03 PeMS07 PeMS08 PeMS-Bay Timesteps 26,208 28,224 17,856 52,116 Number of nodes 358 883 170 325 Number of edges 549 865 276 2,369 Predicted state Volume Volume Volume Mean Speed The length of the input sequence is 15 minutes, and the prediction horizon is set to 15, 30, and 60 minutes. The training, validation, and test sets were split in a ratio of 7:1:2. The Adam optimizer is adopted, and the learning rate is 4×10−44× 10^-4 with a dropout rate of 0.1. The model was trained on an NVIDIA Tesla A800 GPU for 100 epochs, with the first 50 epochs for Stage I and 50 epochs for Stage I to balance training efficiency and the sufficiency of dependency structure learning. Through hyperparameter tuning, we determined the optimal settings: the hidden layer dimension in our SGSAN model is set to 16 for every module, and each temporal attention module has 4 heads. The values for γD _D, γS _S and γI _I in Equations (14) and (15) are 0.1, 1×10−61× 10^-6, and 1×10−31× 10^-3, respectively. 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) [41]: Combines GCNs for spatial topology with GRUs for temporal dynamics. • Spatio-Temporal Graph Convolutional Network (STGCN) [34]: Integrates 1D causal convolutions and graph convolutions without relying on RNNs. • Graph Multi-Attention Network (GMAN) [43]: Employs multiple spatial and temporal attention mechanisms with a transform attention layer. • Attention-based Spatiotemporal Graph Convolutional Network (ASTGCN) [11]: Incorporates spatial and temporal attention mechanisms within a GCN framework. • Spatiotemporal Transformer Network (STTN) [5]: Dynamically models dependencies utilizing self-attention mechanisms across spatial and temporal domains. • Dynamic Spatial-Temporal Trend Transformer (DST2former) [6]: 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) [45]: Utilizes a dual-path architecture to capture dependencies across micro and macro temporal scales. • Causal Conditional Hidden Markov Model (CCHMM) [42]: 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) [32]: Leverages causal discovery algorithms to generate a causal graph prior for spatio-temporal forecasting. V-B Comparative Analysis of Prediction Accuracy TABLE I: Performance Comparison: Prediction Accuracy Dataset Model Horizon=15min Horizon=30min Horizon=60min Average MAE MAPE RMSE MAE MAPE RMSE MAE MAPE RMSE MAE MAPE RMSE PeMS03 T-GCN 20.18 19.13 27.82 29.02 26.65 43.36 36.42 33.86 53.03 28.54 26.55 41.40 STGCN 17.05 14.41 26.76 26.96 25.99 39.58 31.72 29.73 46.78 25.24 23.38 37.71 GMAN 14.87 13.37 23.15 23.65 20.35 36.70 32.00 28.79 47.63 23.51 20.83 35.83 ASTGCN 14.40 12.26 25.17 23.98 20.68 37.71 24.07 20.25 37.65 20.81 17.73 33.51 STTN 16.43 17.38 24.20 22.40 19.12 34.14 27.38 31.77 42.68 22.07 22.75 33.67 DST2Former 16.53 16.25 25.65 20.41 16.54 32.13 24.72 21.96 37.82 20.55 18.25 31.87 DCST 16.24 13.89 26.17 19.13 17.02 34.19 31.26 28.68 46.41 22.21 19.86 35.59 CCHMM 23.16 19.85 35.37 33.96 31.04 50.03 28.19 27.87 41.12 28.44 26.26 42.17 PSTCGCN 16.40 13.50 24.59 19.46 15.96 29.69 21.53 17.35 33.25 19.13 15.60 29.18 SGSAN (Ours) 13.74 11.06 22.56 18.62 15.13 30.71 22.98 18.79 36.74 18.45 14.99 30.00 PeMS07 T-GCN 33.66 15.50 47.55 38.72 18.41 54.38 53.37 28.05 73.81 41.91 20.65 58.58 STGCN 29.91 12.73 44.41 36.78 16.11 53.62 47.04 23.15 65.69 37.91 17.33 54.57 GMAN 26.02 11.47 38.51 34.37 16.64 49.35 47.11 24.90 65.07 35.83 17.67 50.97 ASTGCN 23.29 10.31 35.64 31.42 13.26 46.78 37.41 17.07 53.37 30.71 13.55 45.26 STTN 23.29 11.02 35.47 36.30 16.77 49.95 43.24 19.30 57.50 34.28 15.70 47.64 DST2Former 24.92 10.94 36.50 29.34 12.37 42.15 38.58 18.82 52.99 30.94 14.05 43.88 DCST 24.34 9.91 36.25 27.99 11.51 41.12 35.78 14.62 51.14 29.37 12.01 42.83 CCHMM 34.76 15.46 49.87 41.29 20.46 57.58 48.90 22.49 68.31 41.65 19.47 58.59 PSTCGCN 26.30 15.99 37.39 31.28 18.46 44.27 40.14 24.50 56.08 32.57 19.65 45.91 SGSAN (Ours) 22.84 9.31 35.11 27.47 11.05 40.95 33.89 14.75 50.02 28.07 11.70 42.02 PeMS08 T-GCN 21.19 11.76 30.74 28.94 19.17 41.52 44.07 30.77 61.81 31.40 20.56 44.69 STGCN 21.35 10.01 30.45 25.75 15.25 37.60 34.06 21.71 47.53 27.05 15.66 38.53 GMAN 15.32 9.47 26.55 25.76 16.45 37.16 34.52 22.29 48.46 25.20 16.07 37.39 ASTGCN 15.31 9.13 23.83 22.48 13.08 33.74 29.00 17.19 42.73 22.26 13.13 33.43 STTN 16.41 10.82 23.17 24.11 19.74 33.90 28.11 15.53 40.51 22.88 15.36 32.53 DST2Former 17.91 9.31 25.89 21.02 12.56 31.50 26.05 16.04 37.19 21.66 12.64 31.52 DCST 16.97 9.78 25.65 21.15 12.77 32.67 25.95 15.75 40.26 21.36 12.77 32.86 CCHMM 26.80 16.51 39.91 30.69 20.33 44.49 35.67 23.52 49.72 31.05 20.12 44.71 PSTCGCN 18.43 13.67 26.70 21.89 15.83 31.72 27.65 19.91 39.66 27.65 19.91 39.66 SGSAN (Ours) 14.71 8.59 22.04 20.58 11.74 31.25 24.91 14.60 37.18 20.06 11.64 30.15 PeMS-Bay T-GCN 1.82 3.74 3.40 2.42 5.28 4.71 3.00 6.87 5.74 2.41 5.30 4.62 STGCN 1.78 3.49 3.08 2.60 5.66 4.91 3.33 7.53 6.11 2.57 5.56 4.70 GMAN 1.63 3.41 3.22 2.20 4.89 4.56 2.95 6.95 6.02 2.26 5.08 4.60 ASTGCN 1.54 3.19 3.18 2.10 4.61 4.42 2.77 6.10 5.81 2.14 4.63 4.47 STTN 1.64 3.39 3.18 2.26 4.64 4.20 2.82 6.17 5.11 2.24 4.73 4.16 DST2Former 1.54 3.30 2.97 2.17 4.34 3.94 2.61 5.47 5.18 2.11 4.37 4.03 DCST 1.50 3.19 3.01 1.99 4.27 3.99 2.39 5.23 4.76 1.96 4.23 3.92 CCHMM 1.66 3.43 3.23 2.26 5.05 4.53 3.13 7.31 6.02 2.35 5.26 4.59 PSTCGCN 1.93 4.80 4.26 2.45 5.96 5.15 2.95 7.38 6.17 2.45 6.05 5.19 SGSAN (Ours) 1.48 3.01 2.70 1.99 4.30 3.87 2.38 5.17 4.60 1.95 4.16 3.73 As shown in Table I, 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. V-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 two-stage training framework remain identical to the proposed SGSAN. We introduce a tolerance margin ϵ=0.1ε=0.1 into the dependency structural loss ℒDL_D 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 two-stage 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 randG^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. TABLE IV: Prediction Results in the Ablation Studies Dataset Model Horizon=15min Horizon=30min Horizon=60min MAE MAPE RMSE MAE MAPE RMSE MAE MAPE RMSE PeMS03 STA-GNN 17.70 14.42 28.88 21.30 17.02 34.54 28.36 23.07 44.46 SGSAN (DAG-Relaxed) 16.30 18.36 30.40 20.74 22.95 33.52 24.15 22.71 37.60 SGSAN (Random-DDG) 16.45 17.76 26.30 23.28 26.86 33.10 25.47 26.42 39.07 SGSAN (Joint) 14.05 11.20 22.95 25.59 23.59 38.60 31.72 32.36 44.87 SGSAN (Ours) - KL 15.80 13.35 24.85 20.23 16.12 32.02 24.26 20.90 37.08 SGSAN (Ours) - Cosine 15.57 12.03 23.57 19.91 16.82 31.98 24.22 19.78 37.02 SGSAN (Ours) - MSE 16.75 12.88 22.67 22.09 17.92 31.79 24.35 26.94 36.23 SGSAN (Ours) - InfoNCE 13.74 11.06 22.56 18.62 15.13 30.71 22.98 18.79 36.74 PeMS07 STA-GNN 25.52 11.65 37.73 32.65 14.51 47.61 42.16 19.32 60.06 SGSAN (DAG-Relaxed) 28.87 14.38 39.23 30.86 18.51 42.89 36.16 16.30 53.73 SGSAN (Random-DDG) 27.46 15.21 38.34 30.81 17.71 42.29 34.33 18.74 53.52 SGSAN (Joint) 25.06 11.35 37.20 58.93 29.93 77.35 70.26 36.53 89.04 SGSAN (Ours) - KL 28.36 11.70 38.39 30.79 14.54 44.04 34.99 17.97 52.25 SGSAN (Ours) - Cosine 24.56 13.61 34.67 30.89 15.22 42.31 35.76 17.93 52.18 SGSAN (Ours) - MSE 28.40 11.50 38.62 31.46 14.29 42.61 33.57 16.49 51.39 SGSAN (Ours) - InfoNCE 22.84 9.31 35.11 27.47 11.05 40.95 33.89 14.75 50.02 PeMS08 STA-GNN 18.55 10.64 28.15 22.26 12.56 33.78 30.22 17.49 43.82 SGSAN (DAG-Relaxed) 16.32 9.54 25.89 23.31 16.66 32.25 26.70 18.89 39.59 SGSAN (Random-DDG) 19.92 10.42 27.31 24.28 17.84 32.96 25.92 18.46 41.25 SGSAN (Joint) 15.75 9.78 23.13 24.92 14.62 37.53 26.51 16.19 39.34 SGSAN (Ours) - KL 15.92 9.50 23.79 22.37 12.34 32.06 25.96 18.05 38.89 SGSAN (Ours) - Cosine 15.33 9.19 22.93 22.37 13.14 33.14 26.23 17.12 38.11 SGSAN (Ours) - MSE 15.44 9.28 23.12 22.41 12.49 32.07 25.78 18.66 38.49 SGSAN (Ours) - InfoNCE 14.71 8.59 22.04 20.58 11.74 31.25 24.91 14.60 37.18 PeMS-Bay STA-GNN 1.51 3.08 3.11 2.07 4.59 4.40 2.83 6.74 5.89 SGSAN (DAG-Relaxed) 1.62 3.59 3.07 2.03 4.46 3.92 2.42 5.34 4.66 SGSAN (Random-DDG) 1.61 3.47 3.01 2.02 4.47 3.93 2.39 5.34 4.63 SGSAN (Joint) 2.49 3.75 3.84 3.30 6.54 5.65 3.86 7.02 5.30 SGSAN (Ours) - KL 1.62 3.56 3.05 2.00 4.46 3.91 2.37 5.34 4.66 SGSAN (Ours) - Cosine 1.62 3.55 3.04 2.00 4.43 3.90 2.37 5.39 4.68 SGSAN (Ours) - MSE 1.55 3.28 2.87 1.99 4.36 3.89 2.37 5.28 4.64 SGSAN (Ours) - InfoNCE 1.48 3.01 2.70 1.99 4.30 3.87 2.38 5.17 4.60 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 STA-GNN (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, non-topological 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. V-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. V-D1 Training Efficiency As shown in Table V, this two-stage 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. TABLE V: Average Training Time Per Epoch Model PeMS03 PeMS07 PeMS08 PeMS-Bay SGSAN (Joint) 11.35s 52.21s 4.63s 21.20s SGSAN (Ours) 8.35s 31.73s 3.25s 14.57s Reduction -26.4% -39.2% -29.8% -31.3% V-D2 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). TABLE VI: Inference Efficiency Comparison Model Avg Time per Sample (ms) T-GCN 0.044 ± 0.003 ASTGCN 0.078 ± 0.001 CCHMM 0.079 ± 0.004 SGSAN (Ours) 0.096 ± 0.003 DCST 0.125 ± 0.001 STCGCN 0.136 ± 0.002 DST2Former 0.155 ± 0.002 PSTCGCN 0.434 ± 0.008 SGSAN (Joint) 0.511 ± 0.005 STTN 0.513 ± 0.001 V-E Interpretability Analysis Fig. 2: Sensitivity Analysis of Interpretability Metrics (ASC, SPC, and APC) across varying sparsity levels (Top-K%K\%) (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. 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 ensure the model adaptively balances global structural reliance with local stochasticity. V-E1 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 a trustworthy model should anchor its attention weights to the underlying structural backbone identified in Stage I. A high ASC indicates the effectiveness of the InfoNCE contrastive learning loss. ASC=1B∑b=1B1K|(Ga(b))∩(G∗)|ASC= 1B _b=1^B 1K|\TopK(G^a(b))\∩\TopK(G^*)\| (16) where (⋅)TopK(·) denotes the operation of selecting the top K%K\% of node pairs with the highest weight values. Ga(b)G^a(b) denotes the attention map associated with batch b, and B denotes the total number of batches. While the dependency graph (G∗G^*) remains static, the attention map dynamically adapts to real-time inputs in each batch. A higher ASCASC value indicates a stronger structural prior guiding the attention mechanism. (i) Structural-Physical Consistency (SPC) and Attention-Physical Consistency (APC). While ASC measures internal alignment, there is a risk that the metric is self-referential, as Stage I explicitly integrates the dependency graph and attention maps. To provide an external evaluation, we introduce SPC and APC. SPC measures the overlap between the learned DDG and the actual physical road network adjacency matrix, while APC measures the overlap between the dynamic attention map and the physical network. V-E2 Quantitative Analysis of Structural Consistency This section presents the quantitative results of interpretability using the metrics introduced in Section V-E1. Figure 2 presents a sensitivity analysis of these metrics across varying sparsity levels (from Top-10% to Top-50% retained capacity) for all four datasets. The results yield three crucial insights regarding the model’s interpretability. First, the high SPC scores across datasets demonstrate that our learned dependency graph organically aligns with the physical topology, successfully capturing the true macroscopic structure of the traffic network without any geographic supervision. Moreover, the APC and SPC curves exhibit closely matched values and parallel trajectories across all sparsity levels (e.g., at the Top-30% threshold on PeMS-Bay, SPC and APC reach 0.88 and 0.85, respectively). This proves that the dynamic attention mechanism faithfully inherits the physical alignment of the structural prior. Finally, the ASC metric proves highly robust across varying network densities. The InfoNCE coupling effectively anchors the attention to the core structural skeleton while retaining the numerical freedom required for the attention mechanism to capture real-time, non-topological dependencies. V-E3 Visualization of Graph Alignment This section offers a qualitative analysis of the model’s interpretability, highlighting the visual alignment between the structural dependencies and the attention mechanism. We utilize the sample-specific attention map GaG^a along with the static dependency graph G∗G^* to identify and filter significant node pairs, creating "key subgraphs" for visualization. While the dependency graph remains uniform across all inputs, the attention map varies dynamically. For this visualization, we average the attention weights across the test set and juxtapose them with the dependency graph. The edges in the key subgraphs represent the most significant node-to-node dependencies. Figure 3 demonstrates the relationship dynamics for six typical nodes. A strong consistency between the directed dependencies and the attention-based correlations is evident, with the width of each arrow indicating the weight of the relationship. A key observation is that while the dependency graph is sparser and highly focused, the majority of the dominant paths it identifies are faithfully mirrored in the attention map. Because the dependency graph learns from the macroscopic structure of the entire dataset, it provides the model with a global perspective to identify the true propagation paths of traffic flow. When comparing this Structure-Guided attention map with the baseline STA-GNN, a critical difference emerges. Without structural constraints, standard attention weights tend to be symmetric and undirected, often producing bidirectional arrows that merely reflect statistical correlation rather than physical influence. In contrast, because our dependency graph is constrained to be directed and acyclic, the Structure-Guided attention map adopts these asymmetric relationships. Bidirectional arrows rarely appear, demonstrating that the InfoNCE contrastive learning successfully transfers the directional logic of the physical network into the attention mechanism. SGSAN aligns its prediction process with the actual physical features governing traffic state propagation, thereby making it trustworthy and robust. 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 two-stage 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 performance. In terms of computational efficiency, SGSAN (Ours) outperforms most baselines in inference efficiency, while the two-stage training framework enhances the training efficiency. Furthermore, through newly introduced structural consistency metrics, we verify that the model provides built-in interpretability. The learned DDG achieves an 88% alignment with the physical structure of real networks, without relying on any geographic constraints. By shifting the focus from unconstrained statistical correlations to directed structural dependencies, this work provides a trustworthy, highly accurate, and deployable modeling framework for transportation systems. Acknowledgment This research was supported by [2024YFB4303100, National Key R&D Program of China] and [52402407, the National Natural Science Foundation of China]. References [1] A. Ali, Y. M. Zhu, and M. Zakarya (2021) Exploiting dynamic spatio-temporal correlations for citywide traffic flow prediction using attention based neural networks. Information Sciences 577, p. 852–870. External Links: ISSN 0020-0255 Cited by: §I-A. [2] 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 (2020) Explainable artificial intelligence (xai): concepts, taxonomies, opportunities and challenges toward responsible ai. Information Fusion 58, p. 82–115. External Links: ISSN 1566-2535 Cited by: §I-A. [3] S. Bach, A. Binder, G. Montavon, F. Klauschen, K. Müller, and W. Samek (2015) On pixel-wise explanations for non-linear classifier decisions by layer-wise relevance propagation. PloS one 10 (7), p. e0130140. Cited by: §I. [4] J. D. Bai, J. W. Zhu, Y. J. Song, L. Zhao, Z. X. Hou, R. H. Du, and H. F. Li (2021) A3T-gcn: attention temporal graph convolutional network for traffic forecasting. Isprs International Journal of Geo-Information 10 (7). Cited by: §I-A. [5] C. L. Chen, Y. B. Liu, L. Chen, and C. Q. Zhang (2023) Bidirectional spatial-temporal adaptive transformer for urban traffic flow forecasting. Ieee Transactions on Neural Networks and Learning Systems 34 (10), p. 6913–6925. External Links: ISSN 2162-237x Cited by: 5th item. [6] J. Chen, H. Ye, Z. Ying, Y. Sun, and W. Xu (2025) Dynamic trend fusion module for traffic flow prediction. Applied Soft Computing 174, p. 112979. External Links: ISSN 1568-4946 Cited by: 6th item. [7] Z. Y. Cui, K. Henrickson, R. M. Ke, and Y. H. Wang (2020) Traffic graph convolutional recurrent neural network: a deep learning framework for network-scale traffic learning and forecasting. Ieee Transactions on Intelligent Transportation Systems 21 (11), p. 4883–4894. External Links: ISSN 1524-9050 Cited by: §I-A. [8] R. de Medrano and J. L. Aznarte (2020) A spatio-temporal attention-based spot-forecasting framework for urban traffic prediction. Applied Soft Computing 96. External Links: ISSN 1568-4946 Cited by: §I-A. [9] L. N. N. Do, H. L. Vu, B. Q. Vo, Z. Y. Liu, and D. Phung (2019) An effective spatial-temporal attention based neural network for traffic flow prediction. Transportation Research Part C-Emerging Technologies 108, p. 12–28. External Links: ISSN 0968-090x Cited by: §I. [10] L. Franceschi, M. Niepert, M. Pontil, and X. He (2019) Learning discrete structures for graph neural networks. In International conference on machine learning, p. 1972–1982. Cited by: §I. [11] S. N. Guo, Y. F. Lin, N. Feng, C. Song, and H. Y. Wan (2019) 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, p. 922–929. External Links: ISSN 2159-5399 Cited by: 4th item. [12] S. He, Q. Luo, R. Du, L. Zhao, G. He, H. Fu, and H. Li (2023) STGC-gnns: a gnn-based traffic prediction framework with a spatial–temporal granger causality graph. Physica A: Statistical Mechanics and its Applications 623, p. 128913. Cited by: §I-B. [13] D. Janzing (2019) Causal regularization. Advances in Neural Information Processing Systems 32 (Nips 2019) 32. External Links: ISSN 1049-5258 Cited by: §I. [14] W. Jiang and J. Luo (2022) Graph neural network for traffic forecasting: a survey. Expert systems with applications 207, p. 117921. Cited by: §I. [15] W. Jin, Y. Ma, X. Liu, X. Tang, S. Wang, and J. Tang (2020) Graph structure learning for robust graph neural networks. In Proceedings of the 26th ACM SIGKDD international conference on knowledge discovery & data mining, p. 66–74. Cited by: §I. [16] S. Y. Lan, Y. T. Ma, W. K. Huang, W. W. Wang, H. Y. Yang, and P. Y. Li (2022) DSTAGNN: dynamic spatial-temporal aware graph neural network for traffic flow forecasting. International Conference on Machine Learning, Vol 162. External Links: ISSN 2640-3498 Cited by: §I-A. [17] G. P. Li, V. L. Knoop, and H. van Lint (2021) Multistep traffic forecasting by dynamic graph convolution: interpretations of real-time spatial correlations. Transportation Research Part C-Emerging Technologies 128. External Links: ISSN 0968-090x Cited by: §I-A. [18] Y. Liang, S. G. Li, C. G. Yan, M. Z. Li, and C. J. Jiang (2021) Explaining the black-box model: a survey of local interpretation methods for deep neural networks. Neurocomputing 419, p. 168–182. External Links: ISSN 0925-2312 Cited by: item 2. [19] S. M. Lundberg and S. Lee (2017) A unified approach to interpreting model predictions. Advances in neural information processing systems 30. Cited by: §I. [20] Y. Lv, Y. Duan, W. Kang, Z. Li, and F. Wang (2015) Traffic flow prediction with big data: a deep learning approach. IEEE Transactions on Intelligent Transportation Systems 16 (2), p. 865–873. Cited by: §I. [21] W. J. Murdoch, C. Singh, K. Kumbier, R. Abbasi-Asl, and B. Yu (2019) Definitions, methods, and applications in interpretable machine learning. Proceedings of the National Academy of Sciences 116 (44), p. 22071–22080. Cited by: §I. [22] Z. Y. Niu, G. Q. Zhong, and H. Yu (2021) A review on the attention mechanism of deep learning. Neurocomputing 452, p. 48–62. External Links: ISSN 0925-2312 Cited by: §I-A. [23] J. Pearl (2000) Causality: models, reasoning, and inference. Cambridge University Press, USA. External Links: ISBN 0521773628 Cited by: §I-B, §IV-A. [24] M. T. Ribeiro, S. Singh, and C. Guestrin (2016) "Why should i trust you?": explaining the predictions of any classifier. ACM. Cited by: §I, §I-A. [25] Y. X. Tian and L. Pan (2015) Predicting short-term traffic flow by long short-term memory recurrent neural network. 2015 Ieee International Conference on Smart City/Socialcom/Sustaincom (Smartcity), p. 153–158. Cited by: §I. [26] M. N. Tygesen, F. C. Pereira, and F. Rodrigues (2023) Unboxing the graph: towards interpretable graph neural networks for transport prediction through neural relational inference. Transportation Research Part C-Emerging Technologies 146. External Links: ISSN 0968-090x Cited by: §I-B. [27] A. van den Oord, Y. Li, and O. Vinyals (2018) Representation Learning with Contrastive Predictive Coding. arXiv e-prints, p. arXiv:1807.03748. Cited by: §I, §IV-C. [28] P. Velickovic, G. Cucurull, A. Casanova, A. Romero, P. Lio, Y. Bengio, et al. (2017) Graph attention networks. stat 1050 (20), p. 10–48550. Cited by: §IV-B. [29] E. I. Vlahogianni, M. G. Karlaftis, and J. C. Golias (2014) Short-term traffic forecasting: where we are and where we’re going. Transportation Research Part C-Emerging Technologies 43, p. 3–19. External Links: ISSN 0968-090x Cited by: §I. [30] C. X. Wang, Y. X. Liang, and G. R. Tan (2024) WCityCAN: causal attention network for citywide spatio-temporal forecasting. Proceedings of the 17th Acm International Conference on Web Search and Data Mining, Wsdm 2024, p. 702–711. Cited by: §I. [31] S. Wiegreffe and Y. Pinter (2019) 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, p. 11–20. External Links: Document Cited by: §I. [32] S. Yang, Q. Wu, Z. Li, and K. Wang (2024) PSTCGCN: principal spatio-temporal causal graph convolutional network for traffic flow prediction. Neural Computing and Applications, p. 1–14. Cited by: §I-B, 9th item. [33] X. Yin, G. Wu, J. Wei, Y. Shen, H. Qi, and B. Yin (2021) Deep learning on traffic prediction: methods, analysis, and future directions. IEEE Transactions on Intelligent Transportation Systems 23 (6), p. 4927–4943. Cited by: §I. [34] B. Yu, H. Yin, and Z. Zhu (2018) Spatio-temporal graph convolutional networks: a deep learning framework for traffic forecasting. In Proceedings of the 27th International Joint Conference on Artificial Intelligence (IJCAI), p. 3634–3640. Cited by: 2nd item. [35] Y. Yu, J. Chen, T. Gao, and M. Yu (2019) DAG-GNN: DAG structure learning with graph neural networks. In Proceedings of the 36th International Conference on Machine Learning, K. Chaudhuri and R. Salakhutdinov (Eds.), Proceedings of Machine Learning Research, Vol. 97, p. 7154–7163. Cited by: §I-B, §IV-A. [36] X. Zhai, F. Guo, and A. Sivakumar (2022) A novel interpretability evaluation framework to understand deep learning traffic prediction models. SSRN Electronic Journal. Cited by: §I-A. [37] K. P. Zhang, L. Zheng, Z. J. Liu, and N. Jia (2020) A deep learning based multitask model for network-wide traffic speed prediction. Neurocomputing 396, p. 438–450. External Links: ISSN 0925-2312 Cited by: §I-B. [38] Q. Zhang, C. Huang, L. Xia, Z. Wang, Z. Li, and S. Yiu (2023) Automated spatio-temporal graph contrastive learning. In Proceedings of the ACM web conference 2023, p. 295–305. Cited by: §I. [39] X. Zhang, C. Huang, Y. Xu, L. Xia, P. Dai, L. Bo, J. Zhang, and Y. Zheng (2021) Traffic flow forecasting with spatial-temporal graph diffusion network. In Proceedings of the AAAI conference on artificial intelligence, Vol. 35, p. 15008–15015. Cited by: §I-B. [40] Y. Zhang, P. Tino, A. Leonardis, and K. Tang (2021) A survey on neural network interpretability. Ieee Transactions on Emerging Topics in Computational Intelligence 5 (5), p. 726–742. External Links: ISSN 2471-285x Cited by: §I. [41] L. Zhao, Y. J. Song, C. Zhang, Y. Liu, P. Wang, T. Lin, M. Deng, and H. F. Li (2020) T-gcn: a temporal graph convolutional network for traffic prediction. Ieee Transactions on Intelligent Transportation Systems 21 (9), p. 3848–3858. External Links: ISSN 1524-9050 Cited by: 1st item. [42] Y. Zhao, P. Deng, J. Liu, X. Jia, and M. Wang (2023) Causal conditional hidden markov model for multimodal traffic prediction. In Proceedings of the AAAI Conference on Artificial Intelligence, Cited by: §I-B, 8th item. [43] C. Zheng, X. Fan, C. Wang, and J. Qi (2020) Gman: a graph multi-attention network for traffic prediction. In Proceedings of the AAAI conference on artificial intelligence, Vol. 34, p. 1234–1241. Cited by: 3rd item. [44] X. Zheng, B. Aragam, P. K. Ravikumar, and E. P. Xing (2018) 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, p. . Cited by: §IV-C. [45] Y. Zhou, P. Wang, H. Dong, D. Zhang, D. Yang, Y. Fu, and P. Wang (2024) 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, IJCAI ’24. External Links: ISBN 978-1-956792-04-1 Cited by: 7th item. [46] J. Zhu, J. Yuan, T. Nguyen, R. Wang, and W. Zeng (2025) Traffic prediction using an active causality recurrent graph convolutional network. Expert Systems with Applications, p. 129506. Cited by: §I-B. 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.