## 4 Design of a Capacity-Constrained Weighted Clustering Algorithm
### CH and BCH Node Selection  
After completing the initial partitioning, it enters the stage of selecting cluster heads and backup cluster heads. In a clustering-based topology, the cluster head acts as the hub for information exchange between nodes within the cluster and between clusters, playing a crucial role in enhancing the performance of UAV systems. Meanwhile, during the operation of UAV, there are issues such as high mobility and susceptibility to external interference, which can lead to frequent topology changes. Therefore, in order to achieve better network topology stability in interference environments, this paper introduces interference factors in the cluster head selection process and adopts the mechanism of backup cluster heads. In this paper, we comprehensively consider the key factors that affect the network performance of UAV systems and transform them into cluster head influence factors that are suitable for clustering topology structures, thus completing the design of the optimal cluster head selection algorithm. The cluster head selection factors include connectivity factor, remaining energy factor, mobility similarity factor, average distance factor, and external interference factor. 1. Connectivity Factor  
In UAV networks, network connectivity is crucial as it directly affects the collaborative capabilities of nodes within the network and the success rate of data packet transmission in the network. The connectivity of a node is usually measured by the number of its neighbors, which is the number of other nodes that the node can directly communicate with. Assuming the number of neighbors of node \(i\) in this partition is \(n_{i}\), then the network connectivity of node \(i\) is \(C_{i}=n_{i}\). For node \(i\), if another node \(j\) is within its communication range, it is called a neighbor of the node \(i\). Usually, neighbor relationships need to meet the following conditions [39]:  
\[d(i,j)\leq R_{\max} \tag{1}\]  
where \(d(i,j)\) represents the distance between node \(i\) and \(j\), and \(R_{\max}\) is the maximum transmission radius of wireless communication between nodes. Therefore, the connectivity factor can be normalized as follows:  
\[f_{C_{i}}=\frac{n_{i}}{N_{k}-1} \tag{2}\]  
where \(N_{k}\) is the total number of nodes in this partition. 2. Remaining energy factor  
In UAV cluster network, the cluster head manages intra-cluster data communication as well as inter-cluster data forwarding. Due to its additional responsibilities, the cluster head experiences much higher energy consumption compared to ordinary members. Therefore, the initial remaining energy of nodes must be considered during the cluster head selection process. Assuming that the nodes in the network have the same energy storage capacity, the normalized remaining energy factor of candidate nodes is as follows:  
\[f_{E_{i}}=\frac{E_{ir}}{E_{i}} \tag{3}\]  
where \(E_{i}\) is the maximum energy of the node and \(E_{ir}\) is the current remaining energy of the node. In the execution of tasks, the energy consumption of a UAV system can usually be divided into several key components: flight energy consumption, communication energy consumption, and sensing and data processing energy consumption. This energy consumption should be considered comprehensively to more accurately calculate the remaining energy. The remaining energy of a node can be expressed as follows:  
\[E_{ir}=E_{i}-(E_{icomm}+E_{iflight}+E_{isensor}) \tag{4}\]  
where \(E_{i}\) represents the initial energy of the node, \(E_{icomm}\) represents the communication energy consumption of the node, \(E_{iflight}\) represents the flight energy consumption of the node, and \(E_{isensor}\) represents the sensing energy consumption of the node.