## 4 Model
### Vehicle Cluster Model and Algorithm
In particular, \(v_{i}^{min}\) represents the minimum velocity of the CM in cluster \(c_{i}\). For two clusters, \(c_{i}\) and \(c_{j}\) within the DSRC communication range traveling in the same direction, if the average speeds of \(c_{i}\) and \(c_{j}\) do not change for a period of time in the future, and \(d_{ij}^{cluster}\) tends to shrink (that is, \(c_{i}\) and \(c_{j}\) are close to each other), then \(Y_{ij}\) should be the sum of \(d_{ij}^{cluster}\) and \(R\) divided by the speed difference between \(c_{i}\) and \(c_{j}\); that is, the numerator of Equation (2) should be added. Conversely, if \(d_{ij}^{cluster}\) tends to increase (that is, \(c_{i}\) and \(c_{j}\) are far away from each other), then \(Y_{ij}\) should be the difference between \(d_{ij}^{cluster}\) and \(R\) divided by the speed difference between \(c_{i}\) and \(c_{j}\), and the numerator of Equation (2) should be subtracted. In addition, since the velocities between CMs within a cluster are different, we used the difference between the maximum speed of vehicles in one cluster minus the minimum speed of vehicles in the other cluster as the speed difference between the two clusters, which can make the resulting cluster more stable. Since the number of CM members in the cluster is limited to \(N\), even if the \(D_{ij}^{cluster}\) of \(c_{i}\) and \(c_{j}\) is the largest, once the sum of the number of CMs of \(c_{i}\) and \(c_{j}\) exceeds \(N\), ci and ci cannot be merged. The stopping condition of the clustering algorithm in this paper is until no two clusters with a distance less than \(d_{limit}\) can be found. In summary, the clustering algorithm process in this paper is as follows:  
1. Vehicles report their current state information to the edge server;
2. Initialize clusters, each cluster contains one vehicle;
3. According to Equations (1) and (2), find \(c_{i}\) and \(c_{j}\) in all clusters, such that \(D_{ij}^{cluster}\) is the largest. If the total number of CMs in \(c_{i}\) and \(c_{j}\) is less than \(N\), then \(c_{i}\) and \(c_{j}\) are merged; otherwise, to ensure that the algorithm does not fall into an infinite loop, it is necessary to mark that \(\max\bigl{\{}c_{i},c_{j}\bigr{\}}\) does not enter the next cycle. 4. Repeat step 3 until no more than two clusters that meet the conditions can be identified. The pseudocode of the clustering algorithm is shown in Algorithm 1. Lines 1 to 5 initialize variables. Lines 9 to 10 merge vehicle clusters when the conditions are met. The meaning of the 12 to 13 lines is that if the total number of CMs in the two clusters is greater than \(N\), the larger one of the two clusters will not enter the next loop. vehicle is within the mutual DSRC communication range based on the current situation. \(D_{ij}^{vehicle}\) does not consider whether the vehicles are on the edge of the mutual DSRC communication range, because due to the limitation of \(d_{limit}\), the distance between the vehicles in a cluster and the center of the cluster is less than \(R\), and the final selected CH will also be closer to the center of the cluster. \(D_{ij}^{vehicle}\) is defined as follows:  
\[D_{ij}^{vehicle}=\left\{ \begin{array}{ll}\frac{R+d_{ij}^{v}}{\left|v_{i}^{v }-v_{j}^{v}\right|},v_{i}\text{ and }v_{j}\text{ close to each other}\\ \frac{R-d_{ij}^{v}}{\left|v_{i}^{v}-v_{j}^{v}\right|},v_{i}\text{ and }v_{j}\text{ away from each other} \\ \end{array} \right. \tag{3}\]  
The symbol \(d_{ij}^{vehicle}\) represents the distance between two vehicles, and \(v^{v}\) represents the speed of the vehicle. When \(D_{ij}^{vehicle}\geq D_{threshold}^{vehicle}\), then a stable connection can be established between CM\({}_{i}\) and CM\({}_{j}\), and \(D_{threshold}^{vehicle}\) is a settable threshold. The value of \(D_{threshold}^{vehicle}\) in this paper is the same as that in the TDCR model [13]. In addition, this formula is used to determine whether communication can be established between two CHs when establishing a VANET routing path in Section 5.1.