## 4 Design of a Capacity-Constrained Weighted Clustering Algorithm  
### Network Partition  
After network initialization, a partitioning algorithm is applied to divide the UAV network into regions. Each region will function as a cluster in subsequent tasks, performing different tasks. In this section, the nodes are partitioned based on the K-means++ algorithm [38]. The K-means++ algorithm considers the distance when selecting the initial cluster centers, resulting in a more uniform distribution of initial centers. This approach helps to reduce inter-cluster interference and enhances the overall distribution uniformity of the clusters. Considering the operational characteristics of the UAV network, it has strict requirements for efficient data transmission, low-latency task responses, and strong anti-interference capabilities. If the number of nodes within a cluster is too large, the cluster head will face excessive computational and communication burdens, which could lead to increased network latency and delayed information transmission. This could even result in inconsistent task coordination within the cluster, ultimately affecting operational efficiency. Furthermore, an overly large cluster is more likely to become a primary target for external interference, reducing the system's security. Therefore, to enhance the network's stability, communication efficiency, and anti-interference ability, it is necessary to limit the number of nodes within each partition, ensuring efficient communication within the partition and maintaining the system's stability in complex environments. To address this, a capacity-constrained partitioning algorithm based on K-means++ is proposed. Compared to the traditional K-means++ algorithm, the improved K-means++ algorithm introduces additional constraints to limit the maximum number of nodes. It also adaptively relaxes these constraints for nodes that cannot be allocated in the first round, ultimately achieving balanced control of partition capacity. Furthermore, the algorithm ensures high-quality allocation results and stability by using a distance-based node partitioning allocation order. The process of this algorithm is controllable and highly transparent, making it particularly suitable for practical combat scenarios that need to consider both similarity-based partitioning and capacity balance. And it effectively addresses the potential partitioning imbalance that may arise in the traditional K-means++ algorithm. The process of the capacity-constrained K-means++ algorithm is shown in Figure 5.  
Figure 5: Partition algorithm process. Through the integration of processes, the detailed summary description of the steps is as follows:  
Step 1: Randomly select a node in the network as the first partition center (seed node). Step 2: Calculate the Euclidean distance from all unselected points to the center of the currently selected partition. Step 3: Based on the square of the distance as the probability distribution, select a node from the unselected nodes with a larger distance from the selected partition center as the new partition center. Step 4: Repeat steps 2-3 until the predetermined K partition centers are selected. Step 5: Calculate the distances between all unselected nodes and K partition centers, and sort all points by their distance to the nearest partition center. Step 6: In sorted order, start by allocating the points with the smallest distance, and sequentially assign them to the nearest cluster that has not yet reached its maximum capacity limit \(N_{\text{max}}\). Step 7: For the points that cannot be allocated in the first round, a dynamic relaxation strategy is adopted: the initial relaxation capacity is set to \(N_{\text{max}}+1\), and attempts to allocate unallocated points to underfilled clusters based on a distance-priority order. If there are still unallocated points, gradually increase the relaxation amplitude until the maximum relaxation value is reached or all points are allocated. Step 8: Output the final partition results.