# Pedestrian Trajectory Prediction Based on Dual Social Graph Attention Network
## 3 Methods
### Dual Social Graph Attention Network
#### 3.3.3 Group Attention Function  
Group behavior activities are an important part of pedestrian interactions. Groups usually have similar behavioral patterns or destinations, so pedestrians often exhibit the same characteristics in group walking activities. Therefore, separating groups from the crowd and encoding their features can help improve the accuracy of pedestrian trajectory prediction. Similar to the dual-branch spatiotemporal graph neural network Social-TAG [17], we need to identify and separate groups in the crowd and encode them into an adjacency matrix. Unlike Social-TAG, we have improved the definition of groups and quantified the interaction intensity within groups, and then performed spatiotemporal convolution through the Spatiotemporal Graph Convolutional Network (STGCN) to aggregate the spatiotemporal information of groups. In the scenario depicted in Figure 4, nine pedestrians (labeled 1 to 9) exhibit distinct movement characteristics, including varying directions and speeds. We determine the group affiliations based on their behavioral patterns, which are essential for constructing the group graph.  
Our definition of groups is based on the behavioral logic of pedestrian groups. Groups in the crowd have similar ways of behaving. As a group of pedestrians, their direction of movement should be similar, the distance between pedestrians should be close, and their walking speed should be similar. Therefore, to determine whether pedestrians belong to the same group, these three conditions must be met simultaneously. As shown in Figure 4, pedestrian 3 is not in the same group as pedestrians 1 and 2 because the angle of their walking direction is too different, although pedestrian 3 is close to pedestrians 1 and 2. At the same time, pedestrian 9 is not in the same group as pedestrians 4 and 5 because their speed difference is too large, although the distance between pedestrian 9 and pedestrians 4 and 5 is close and the angle of their walking direction is also close. The changes of groups are particularly evident in the temporal dimension, so we make group determinations for the crowd at each time step and encode them into the adjacency matrix for propagation in the model. In the function we designed, thresholds are used to judge the direction of travel, the distance between pedestrians, and the speed of pedestrians to divide the groups. We compare each pedestrian in the crowd one by one, taking pedestrians \(i\) and \(j\) as an example for group determination.  
Figure 4: Group division in crowds.  
\[\left\{\begin{aligned} \left\|\left(x_{i}^{t},y_{i}^{t}\right)- \left(x_{i}^{t},y_{i}^{t}\right)\right\|_{2}&\leq L_{position}\\ \angle\theta\Big{(}v_{i}^{t},v_{j}^{t}\Big{)}&\leq L_{ direction}\\ \left\|v_{i}^{t}-v_{j}^{t}\right\|_{2}&\leq L_{ velocity}\end{aligned}\right. \tag{11}\]  
In Equation (11), we calculate the Euclidean distance between pedestrian \(i\) and pedestrian \(j\), and judge the distance between them based on the position restriction threshold \(L_{position}\). At the same time, we calculate the angle \(\angle\mathcal{D}\) between the velocity vectors of pedestrian \(i\) and pedestrian \(j\), and judge the difference in their direction of travel based on the angle restriction threshold \(L_{direction}\). Finally, we calculate the relative speed of the two people and judge it based on the speed restriction threshold \(L_{direction}\). Only when pedestrians meet these three restriction conditions simultaneously can they be determined to belong to the same group. After the group determination is completed, we use the reciprocal of the Euclidean distance between pedestrians to quantify the interaction intensity between them. The smaller the distance between pedestrians, the greater the interaction intensity, which is consistent with the actual interaction situation.