## 5 Algorithm
### RSU Clustering
Specifically, the weight is determined by the cosine similarity of their required block sets, multiplied by the Gaussian kernel function of their physical distance \(d_{ij}\):  
\[w_{i,j}=s_{B}(r_{i},r_{j})=\frac{\left\|B_{r_{i}}\cap B_{r_{j}}\right\|_{1}}{ \left\|B_{r_{i}}\right\|_{2}\cdot\left\|B_{r_{j}}\right\|_{2}}\cdot GK(r_{i},r _{j}) \tag{16}\]  
where \(\left\|B_{r_{i}}\right\|_{2}=\sqrt{\left|B_{r_{i}}\right|}\) represents the number of blocks required by RSU \(r_{i}\), \(\left\|B_{r_{i}}\cap B_{r_{j}}\right\|_{1}\) denotes the number of blocks that RSU \(r_{i}\) and \(r_{j}\) have in common demand, and \(GK(r_{i},r_{j})\) represents the Gaussian kernel function, which quantifies the spatial aggregation of RSU nodes based on their geographical proximity. It is defined as follows:  
\[GK(r_{i},r_{j})=\exp(-d_{ij}^{2}/\sigma^{2}) \tag{17}\]  
where \(\sigma\) is a parameter that controls the strength of the distance relationship. Based on the above block demand similarity definition, the similarity matrix between nodes can be expressed as follows:  
\[W_{RSU}=\left[ \begin{array}{ccc}w_{1,1}&\cdots&w_{1,N}\\ \vdots&\ddots&\vdots\\ w_{N,1}&\cdots&w_{N,N}\end{array} \right] \tag{18}\]  
At the same time, for each RSU node, its degree can be computed as \(d_{i}=\sum_{j=1}^{N}w_{i,j}\). Thus, the degree matrix \(D_{RSU}\) can be expressed as follows:  
\[D_{RSU}=\left[ \begin{array}{ccc}d_{1}&\cdots&\cdots\\ \vdots&\ddots&\vdots\\ \cdots&\cdots&d_{N}\end{array} \right] \tag{19}\]
3. Laplacian Matrix Computation: After obtaining the similarity matrix \(W_{RSU}\) and the degree matrix \(D_{RSU}\), the Laplacian matrix can be expressed as \(L_{RSU}=D_{RSU}-W_{RSU}\). At the same time, we perform normalization on the Laplacian matrix, yielding \(L_{norm}\): \[L_{norm}=D^{-1/2}LD^{-1/2}\] (20)
4. Spectral Decomposition: Perform eigen decomposition on the normalized Laplacian matrix \(L_{norm}\) to obtain the eigenvalues \(\Lambda=\{\lambda_{1},\lambda_{2},\cdots,\lambda_{N}\}\) and the corresponding eigenvectors \(U=\{u_{1},u_{2},\cdots,u_{N}\}\). From these, select the smallest \(L\) eigenvalues\(\lambda_{1}\sim\lambda_{L}\) and construct the matrix \(U_{L}=\{u_{1},u_{2},\cdots,u_{L}\}\) by using their corresponding eigenvectors as column vectors. 5. Feature Normalization: Normalize each row of the eigenvector matrix \(U_{L}\) to obtain the final feature matrix \(F\). 6. K-means Clustering with Minimum Capacity Constraint: Using each row of the feature matrix \(F\) as an input sample, perform K-means clustering with constraints, obtaining the clustering result \(CLU\). ```
0: RSU set \(R\), vehicle set \(V^{i}\) within each RSU coverage area
0: number of clusters \(L\), RSU Cluster \(CLU\)
1:\(L\leftarrow\left\lfloor\frac{\sum\
olimits_{j\in R}r_{ij}}{\eta\sum\
olimits_{k =1}^{K}\kappa_{k}}\right\rfloor\)
2:for each pair of RSU nodes \(r_{i}\) and \(r_{j}\)do
3: Compute the Euclidean distance \(d_{ij}\) between nodes \(r_{i}\) and \(r_{j}\) based on the location information \(\{x_{r_{i}},y_{r_{i}}\}\) and \(\{x_{r_{j}},y_{r_{j}}\}\)
4: Compute the weight \(w_{i,j}\) between \(r_{i}\) and \(r_{j}\) based on \(B_{r_{i}}\) and \(B_{r_{j}}\): \(w_{i,j}=s_{B}(r_{i},r_{j})=\frac{\left\|B_{r_{i}}\cap B_{r_{j}}\right\|_{j}}{ \left\|B_{r_{i}}\right\|_{2}\left\|B_{r_{j}}\right\|_{2}}\cdot GK(r_{i},r_{j})\)
5:endfor
6: Construct the similarity matrix \(W_{RSU}\)
7: Compute the node degree \(d_{i}=\sum\
olimits_{j=1}^{N}w_{i,j}\) and obtain the degree matrix \(D_{RSU}=\{d_{i}\}\)
8: Compute the Laplacian matrix \(L_{RSU}=D_{RSU}-W_{RSU}\)
9: Normalize the Laplacian matrix \(L_{norm}=D^{-1/2}LD^{-1/2}\)
10: Perform eigen decomposition on the normalized Laplacian matrix \(L_{norm}\) to obtain eigenvalues \(\Lambda=\{\lambda_{1},\lambda_{2},\cdots,\lambda_{N}\}\) and corresponding eigenvectors \(U=\{u_{1},u_{2},\cdots,u_{N}\}\)
11: Select the smallest \(L\) eigenvalues \(\lambda_{1}\sim\lambda_{L}\) and form the matrix \(U_{L}=\{u_{1},u_{2},\cdots,u_{L}\}\) with their corresponding eigenvectors as column vectors.