## 4 Proposed Clustering Algorithm
### CH Selection Approach (Classical)  
Based on the preceding assumptions, in this work, an algorithm called the classical weighted clustering algorithm (CWCA) is proposed to efficiently combine the necessary parameters, such as the node degree, node-to-node average distance, and current residual energy, with certain weighting factors being chosen according to the network system. In wireless networks, for instance, power regulation is crucial, and hence, the weight of the corresponding parameter might be larger. The adaptability from altering the weighted variables enables us to apply this proposed method across different networks. A predefined value/threshold for node degree needs to be set in the clusters to ensure that the cluster heads are not encumbered and that throughput is achieved by optimizing the number of member nodes of each cluster head (the node degree). In addition, the battery power of a sensor node needs to be effectively utilized within a particular transmission range; for instance, communication between the nodes will use less power if they are close to one another. Since a CH is responsible for additional tasks, it uses more battery power than an ordinary node does. It can interact more smoothly with the neighbors within the transmission range and those located closer to it. Due to signal attenuation, communication between the nodes and the CH becomes challenging as the distance increases. According to [42], this has been considered for wireless ad hoc networks, so we modified it, and we propose it for our algorithm. Considering all the above preliminaries, the CH selection procedure consists of the following steps. Step 1: Within transmission range, find the neighbors of each node, \(s\), which define their node degree, \(d_{s}\), as follows:  
\[d_{s}=|\ N(s)|=\sum_{n\in S}\{dist(s,n)<r_{tx}\} \tag{9}\]  
where \(d_{s}\) represents the degree of each sensor node \(s\); S = the set of sensor nodes; \(n\) = the neighbors of sensor node s; \(r_{tx}\) = the transmission range of sensor node s.  
Step 2: Evaluate the degree difference, \(d_{f}\), for every node. \[d_{f}=|\ d_{s}-\gamma| \tag{10}\]  
where \(d_{f}\) = the current node degree of the sensor node, and \(\gamma\) = the expected or predefined node degree. Step 3: Compute the sum of the distances of the member nodes within the transmission range, and find the average distance, \(D_{avg}\):  
\[D_{s}=\sum_{n\in\ S(s)}\{\text{dist}(s,n)\} \tag{11}\]  
Average distance \(D_{avg}=\frac{\sum D_{s}}{d_{s}}\). Step 4: Compute the residual energy to find the node with the highest energy level:  
\[E_{s}=\frac{E_{re}(s)}{E_{i}(s)} \tag{12}\]  
where \(E_{re}\)(s) = the residual energy of node s, and \(E_{i}\)(s) = the initial energy of node s.  
Step 5: Calculate combined weight, \(W_{s}\), for each node s which might become a CH. The lowest weighted node will be chosen as CH:  
\[W_{s}=\ w_{1}\Delta s+w_{2}D_{avg}+w_{3}E_{s} \tag{13}\]  
where \(w_{1}\), \(w_{2}\), and \(w_{3}\) are the weight factors for the corresponding system parameters. The node with the minimum weight will be selected as the cluster head, so:  
\[w_{1}+w_{2}+w_{3}=1 \tag{14}\]  
The first component, \(\Delta\)s, or the node degree difference, is the important factor for a CH in order to control several nodes in its cluster. This also ensures that the CH is not overloaded, and the efficiency of the system is retained at the intended level. The second component \(D_{avg}\), is mainly related to energy consumption because more power is required to communicate over a larger distance. It is important to find the node which is located at the center of a cluster. The last component, \(E_{s}\), contemplates a sensor node's available battery power. The CH battery drainage will occur quickly compared to that which occurs in other nodes. Within the transmission range, each node compares its energy level with the other nodes. The node with the highest energy level has an increased probability of becoming the CH.