## 3 Vehicle Clustering Algorithms
### Vehicle Clustering Method Based on DBSCAN Algorithm
In each cluster, the node within the communication range of RSU, that is, the distance between the vehicle node \(i\) and the RSU meets the constraint conditions \(d_{\text{RI}}<R\), and the node closest to the RSU is selected as the cluster head. As the DBSCAN algorithm is insensitive to abnormal vehicle nodes and is capable of discovering clusters of arbitrary shapes with fast clustering speed without the need to divide the number of clusters, it aligns well with the research scenario of this paper. Thus, the vehicle clusters are established during the initial phase and there is no need to re-form new clusters in each subsequent round, which reduces the energy consumption during the cluster establishment phase throughout the entire process, thereby improving the overall network lifespan. ### Algorithm Description

The pseudo-code of the improved D-LEACH algorithm based on Algorithm 1: the DBSCAN algorithm is described in Algorithm 2. ```
% Network Initialization % Cluster Formation Process % Using DBSCAN clustering algorithm DBSCAN_Params = Set Parameters() % Set parameters required for DBSCAN [clusters, noise] = DBSCAN_Algorithm() % Perform DBSCAN clustering on nodes, returning clustering results and noise points %%Iterate to divide all nodes into clusters Election_of_Cluster_heads = Find Cluster Heads() % Find the nodes closest to the cluster center as cluster heads Broadcast() % Cluster heads broadcast messages to cluster members Receive_msg() % Nodes receive messages sent by cluster heads %%Data Transmission Process Send Data to CH() % Cluster member nodes send data to cluster heads If (id == id_head) ReNode Data() % Receive data from cluster member nodes Send Data to BS() End
```

**Algorithm 2**The D-LEACH algorithm

The steps of the Algorithm 2: the D-LEACH algorithm are shown in Table 1. \begin{table}
\begin{tabular}{c c} \hline \hline
**Initialization** & **Network Initialization** \\ \hline Cluster Formation Process (Using DBSCAN clustering algorithm) & Set parameters required for DBSCAN \\  & Perform DBSCAN clustering on nodes, returning \\  & clustering results and noise points \\  & Find the nodes closest to the cluster center as cluster heads \\  & Cluster heads broadcast messages to cluster members \\  & Nodes receive messages sent by cluster heads \\  & Cluster member nodes send data to cluster heads \\  & Cluster head receives data from cluster member nodes \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Process of the D-LEACH algorithm. The detailed flow chart of the Algorithm 2: the D-LEACH algorithm is shown in Figure 2.

## 4 Simulation Verification

In this study, the MATLAB R2019a software is used to perform simulation analysis on a scenario of a dual carriageway with four lanes in each direction. The communication mode is a combination of V2V and V2I communications on the highway, and the vehicles in the heterogeneous traffic flow consist of both CAVs and HVs. First, simulations are conducted on the traditional LEACH protocol and the improved algorithm proposed in this paper, and the performance is compared in terms of network energy consumption and the number of dead nodes. Next, the improved D-LEACH algorithm is used to simulate the performance of heterogeneous traffic flow networks under different permeabilities, and the variations of network connectivity, heterogeneous cluster length, and RSU deployment interval with CAV permeability are discussed. Figure 2: Flowchart of D-LEACH algorithm.