## 2 Materials and Methods
### WSN Simulation Setup
#### 2.1.1 Static and Dynamic WSN Simulation  
This paper investigates the performance of our proposed CWGO algorithm with static and dynamic sensor nodes through simulation. This approach helps determine whether our technique can perform well in stable and dynamic environments. In the static WSN simulation, sensor nodes are randomly deployed within a predefined area. Once deployed, the nodes remain stationary throughout the simulation. This scenario reflects real-world applications where sensor nodes are fixed in place. Each node is assigned to a specific cluster, with one node per cluster serving as the CH responsible for aggregating data cluster members and transmitting it to the sink node or base station. Selecting CHs is critical for optimizing energy consumption as it has higher energy demands due to data processing and long-range transmission tasks. In the static simulation, the CWGO and algorithms, like E-CERP, EECHIGOWO, DUCISCA, and DE-SEP, dynamically select the optimal CH based on several factors. This process minimizes energy dissipation across the network, extending its lifespan. In dynamic WSN scenarios, mobility becomes a significant factor for applications like wildfire tracking, mobile healthcare, and intelligent transportation systems, where sensor nodes either move or must be redeployed due to environmental or operation changes. Our sensor node's positions are updated at the start of each simulation round to simulate mobility. This dynamic movement requires optimization to adapt their CH selection and routing strategies for each round. In addition, the nature of networks complicates the task of maintaining balanced energy distribution. As sensor nodes move, some nodes must transmit data over long distances, which increases energy consumption. At the end of each static and dynamic simulation scenario, the total distance traveled during the transmission of data by each node is calculated. The distance is calculated based on the value of the intra-cluster and inter-cluster distance presented in Equations (1) and (2), respectively:  
\[\delta_{1}=\frac{1}{\beta_{1}mn}\sum\
olimits_{r=1}^{m}\sum\
olimits_{s=1- \
eq s}^{n}l_{rs} \tag{1}\]  
\[\delta_{2}=\frac{1}{\beta_{2}n}\sum\
olimits_{s=1}^{n}\sum\
olimits_{e=1}^{n} l_{se} \tag{2}\]  
where  
\(l_{rs}\) is the distance between \(r\)th and \(s\)th CHs;  
\(\beta_{1}\) and \(\beta_{2}\) represents the normalization constant/factor;  
\(\delta_{1}\) is the intra-cluster distance;  
\(m\) is the node count;  
\(n\) is the CH count;  
\(\delta_{2}\) is the inter-cluster distance;  
\(l_{se}\) is the distance between \(s\)th and \(e\)th CHs. The transmission delay, expressed in Equation (3), is also calculated. It represents the time the data packet travels from node \(e\) to the CHs:  
\[\vartheta=\sum\
olimits_{i=1}^{n}\frac{A_{i}}{m} \tag{3}\] \begin{table}
\begin{tabular}{c c c c c c} \hline
**Parameter** & **Proposed CWGO** & **DE-SEP** & **E-CERP** & **DUCISCA** & **EECHIGOWO** \\ \hline Clustering Technique & K-Means & K-Means & K-Means & K-Means & K-Means \\ \hline \multirow{3}{*}{Data Packet Size} & Random varies & Random varies & Random varies & Random varies & Random varies \\  & between 1 and 10 & between 1 and 10 & between 1 and 10 & between 1 and 10 & varies between 1 \\  & per round & per round & per round & per round & and 10 per round \\ \hline \end{tabular}
\end{table} 
Table 1: _Cont._where  
\(A_{i}\) refers to the node count in the \(i\)th CH;  
\(m\) is the node count;  
\(n\) is the CH count;  
\(\theta\) represents the delay in seconds. Three kinds of trust, such as direct (DT), indirect (IT), and error-based (ET) trust, are also calculated to determine the trustworthiness of each node in the network. Each trust value is calculated using Equations (4)-(6) for the DT, IT, and ET. The average of the three trust values then represents the overall trust of the network.