## 3 The Proposed Traffic Flow-Prediction Model
### The Random Walk Mechanism Based on Multi-Graph Attention  
To thoroughly investigate the impact of traffic accidents and congestion, the regions of a city are encoded where abnormal traffic events occurred at the same time intervals so as to extract the positional features and spatial details of the abnormal traffic events. Next, the encoded regional graph is subjected to a multi-graph attention mechanism to dynamically model the spatial correlations of various kinds of abnormal events, as local subgraphs. When the captured abnormal traffic events occur between regions, the spatial features can be captured via the introduced attention mechanism to especially focus on the common variations in the traffic data across regions after the occurrence of the same type of abnormal event. Therefore, spatiotemporal features can be extracted via the multi-graph attention mechanism with the random walk mechanism. When traffic anomalies occur in the future, the random walk mechanism can account for the local and global traffic flow changes in the urban regional network.  
1. Location coding Map coding is applied [29] to extract the future location of the abnormal traffic events, representing potential traffic congestion. The coded location is used as the location accident information, and the event location feature \(b_{t}^{i}\) is represented as the one-hot vector \(b_{t}^{it}\in R^{v+\beta}\), where \(v\) is the amount of time intervals. Let \(\beta=N\) represent the number of urban areas. Thus, the accident location coding \(b_{t}^{i}\) can be embedded in \(AE^{i}\in R^{T\times(v+\beta)}\), \[AE_{t}^{i}=f({\mu}_{t,1}^{i}\cdot\text{ReLU}({\mu}_{t,0}^{i}{b}^{i}_{t}+{d}_{t,0}^{i})+{d}_{t,1}^{i})\] (2) where \(f(\cdot)\) is an activation function and \(\left\{{\mu}_{t,0}^{i},{d}_{t,0}^{i},{\mu}_{t,1}^{i},{d}_{t,1}^{i}\right\}\) are the learnable parameters in different layers of the network.
2. Multiple subgraph attention modules According to the location feature \(AE^{i}\), the subgraph \(B\) is formed via the historical traffic data \(\kappa=\{\kappa_{1},\kappa_{2},\cdots,\kappa_{B}\}\). Then, the historical traffic data from various regions with the same abnormal event type at different time steps are aggregated as a virtual node \(v\), and the node subset (\(V_{b}\)) is constructed with \(K\) neighboring regions. Then, the traffic flow data are integrated into subgraph \(B\) via the Graph Attention (GAT) block as [39], \[S_{v,i,v,b}=a(<W_{b}{h}l_{v;b}^{l-1}\cdot W_{b}{h}l_{v,b}^{l-1}>)\] (3) \[\alpha_{vi,v,b}=\frac{\exp(s_{vi,v,b})}{\sum_{v\in V_{b}}\exp(s_{vi,v,b})}\] (4)\[h_{vi,b}^{(I)}=\sum_{v\in V_{b}}\alpha_{vi,v,b}hl_{vi,b}^{l-1} \tag{5}\]  
where \(vi\) is the hidden state of the node, denoted as \(hl_{vi,b}^{(l-1)}\), representing the \(b^{\text{th}}\) GAT block (\(1\leq b\leq B\)); \(s_{vi,v,b}\) represents the correlation coefficient between node \(v\) and the adjacent node \(vi\); \(W_{b}\) is the hyper-parameter of the \(b^{\text{th}}\) graph. \(\|\cdot\|\) denotes the concatenation operation; \(<\cdot,\cdot>\) represents the inner product; \(a(\cdot)\) is a single-layer feed-forward neural network which maps the concatenated high-dimensional features to a real number. For the \(b^{\text{th}}\) GAT block, the output of the multi-subgraph attention module is represented as \(\chi_{ms,b}\in R^{P\times U\times V}\).  
Considering the highly dynamic characteristics of the traffic flow conditions in the accident-prone regions, the impact on the traffic flow of the surrounding areas varies along with time and different types of ambient events. Here, the output of the multi-subgraph attention module is used with a random walk mechanism (RWA) to adaptively capture the correlations among various neighboring target nodes at low computational cost, improving the system ability to adapt to local variations in different abnormal event locations.