## 4 Proposed Clustering Algorithm
### CH Selection Approach (Classical)
Overall, this term is dependent on the node's starting power along with the power needed over time based on the network traffic. The flowchart for the proposed cluster head selection is presented in Figure 3.  
Figure 3: Flowchart of cluster head selection and cluster formation in the CWCA algorithm. An Illustrative Example  
In our proposed classical weighted algorithm, we assume that 15 nodes are initially deployed in an area 50 m \(\times\) 50 m, as shown in Figure 4a. The red arrow shows each node's transmission range (\(r_{tx}\)), which is equal for all of the nodes, and the dotted circles represent the transmission area (\(A_{s}\)). Figure 4b identifies the neighbor(s) of sensor nodes within the transmission range \(r_{tx}\). For instance, node 11 has only one neighbor within the transmission range \(r_{tx}\), whereas node 10 and node 2 have five and three neighbor nodes, respectively. Therefore, in Table 2, the current node degree \(d_{s}\) is calculated according to Figure 4b. The degree difference is important and needs to be set, otherwise, some clusters will be heavily loaded, and others will be lightly loaded. To quantitatively determine the well-balanced clusters in our algorithm, we use the following expression for degree difference:  
\[\gamma=\frac{N-k_{opt}}{k_{opt}} \tag{15}\]  
Figure 4: (**a**) Initial deployment of sensor nodes; (**b**) identification of neighbor nodes, (**c**) an example of the node-to-node distance calculation; (**d**) identification of the cluster head using the CWCA. \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline \multirow{2}{*}{**Node ID**} & **Current Node** & **Current and Expected Node** & **Normalized Node** & **Sum of All Member** & **Average Distance** & **Energy Ratio** & **Total Weight** \\  & **Degree, \(d_{s}\)** & \(d_{s}\)** & **Degree Difference,** & **Degree Difference,** & **Node Distances** & \(D_{avg}\frac{\sum D_{s}}{d_{s}}\) & \(E_{s}\frac{E_{avg}}{E_{avg}}\) & **Total Weight** \\  & & \(d_{s}\)** & \(d_{s}\)** & \(d_{s}\)** & \(d_{s}\)** & \(E_{s}\frac{E_{avg}}{E_{avg}}\) & **\(W_{s}\)** \\ \hline
1 & 3 & 4 & 0.57 & 11 & 3.67 & 1 & 1.23 \\ \hline
2 & 3 & 3 & 0.43 & 12 & 4 & 1 & 1.20 \\ \hline
3 & 2 & 5 & 0.71 & 10 & 5 & 1 & 1.60 \\ \hline
4 & 2 & 5 & 0.71 & 15 & 7.5 & 1 & 2.10 \\ \hline
5 & 4 & 3 & 0.43 & 9 & 2.25 & 1 & 0.85 \\ \hline
6 & 2 & 5 & 0.71 & 3 & 1.5 & 1 & 0.90 \\ \hline
7 & 4 & 3 & 0.43 & 16 & 4 & 1 & 1.20 \\ \hline
8 & 3 & 4 & 0.57 & 6 & 2 & 1 & 0.90 \\ \hline
9 & 2 & 5 & 0.71 & 12 & 5 & 1 & 1.60 \\ \hline
10 & 5 & 2 & 0.29 & 10 & 2 & 1 & 0.70 \\ \hline
11 & 1 & 6 & 0.86 & 6 & 6 & 1 & 1.90 \\ \hline
12 & 2 & 5 & 0.71 & 11 & 5.5 & 1 & 1.70 \\ \hline
13 & 4 & 3 & 0.43 & 7 & 1.75 & 1 & 0.75 \\ \hline
14 & 5 & 2 & 0.29 & 12 & 2.4 & 1 & 0.78 \\ \hline
15 & 3 & 4 & 0.57 & 13 & 4.33 & 1 & 1.37 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Calculation of CH selection parameters, and implementation of the CWCA. In this example, the total number of nodes \(n=15\), the area \(A=50\) m \(\times\)\(50\) m, and the node density \(\rho=\dfrac{n}{A}=\dfrac{15}{2500}\) m\({}^{-2}=0.006\) m\({}^{-2}\). Hence, no node is isolated, based on Figure 4a, and the probability of connectivity will be 99%. Now, we can determine that our expected transmission range from Equation (3) is 20 m. Therefore, the transmission area of each sensor node (\(\text{A}_{\text{S}}=\pi r_{\text{tr}}{}^{2}\)) will be 1256 m\({}^{2}\). The expected number of clusters (\(k_{opt}\)) for area A can be computed as \(E_{n}=\dfrac{50~{}\times~{}50}{1256}\approx 2\). From Equation (15), we calculate the expected node degree difference (\(\gamma\)) as 6.5-7. The sum of the distances, \(D_{\text{S}}\), for each sensor node is shown in Figure 4c, where the unit distance was chosen randomly. To ensure that the probable location of the CH is in the center, we consider the average distance, \(D_{\text{agg}}\), instead of taking the sum of \(D_{\text{S}}\).