# A Hybrid Unequal Clustering Based on Density with Energy Conservation in Wireless Nodes
## 3 The Proposed HCD Algorithm
### Protocol Performance
#### 3.2.1 Cluster Initialization  
In this stage, network nodes are divided into groups to form clusters. In the first phase, when the network is operational, the probability of each node to become a CH and its cluster radius are determined based on the energy level of the node and its distance to the BS. Nodes calculate their own cluster radius according to Equation (4). \[R_{c}(i)=\left[1-\alpha(\frac{d_{BS,\max}-d_{i,BS}}{d_{BS,\max}-d_{BS,\min}})- \beta(1-\frac{E_{rem}(i,r)}{E_{Max}})\right]RL_{\max}\times\lambda \tag{4}\]  
In the above-mentioned Equation, \(R_{c}(i)\) is the radius of node \(i\) and \(RL_{max}\) is maximum competition radius for being a CH, as determined previously. \(E_{rem}(i,r)\) is the remaining energy of the node \(i\) in the round \(r\) and \(E_{max}\) stands for the maximum energy capacity of the node. \(d_{BS,max}\) and \(d_{BS,min}\) are the maximum and minimum distance of nodes from the BS and \(d_{i,BS}\) is the distance of \(i_{\text{th}}\) node from the BS. \(\alpha\) and \(\beta\) are also weight factors that can vary between zero and one. \(\lambda\) is the weight factor associated with the layer where the nodes are located. In the lower layers \(RL_{max}\) is multiplied by a smaller coefficient to the nodes which are closer to the BS and, thus, has a smaller radius. In contrast, further clusters are multiplied by a greater coefficient to have a larger radius. Accordingly, if a node is selected as a CH it will have more energy to receive and transmit the data than the further CH to the BS. Before computing delay time, each node shares its location information and energy level with its neighbors. All nodes, which are situated in its radio range, receive the node's message from all neighbors. After informing the nodes of their neighbors, they are able to calculate the average energy of neighbor's nodes which is calculated using Equation (5). \[E_{Ave}(i,r)=\frac{\sum\limits_{j\in N_{\text{hbr}}(i,r)}E_{rem}(j,r)}{\max(|N _{\text{hbr}}(i,r)|,\varepsilon)} \tag{5}\]  
\(N_{\text{hbr}}(i,r)\) is the number of sets of nodes of neighbors \(i\) in the round of \(r\). \(|N_{\text{hbr}}(i,r)|\) is node degree or number of neighbors for node \(i\) in the round \(r\). The parameter \(\varepsilon\) is a very small number in order to avoid infinity caused by division by zero. Each node will give itself a scoring point parameter in order to start the routine of becoming a CH based on density. In the first cluster initialization stage, the point of CH for each node is zero. Each node considers its neighbors and if the energy level of the neighbor is smaller than its own energy level, it increases its point by one unit. The scoring point needed for each node to become a CH is updated after the computation given in Equation (6). \[ \begin{array}{llll}\forall&j\in N_{\text{hbr}}(i,r)\\ if&E_{rem}(i,r)>E_{rem}(j,r)&then&p(i)=p(i)+1\\ if&\left|N_{\text{hbr}}(i,r)\right|>\left|N_{\text{hbr}}(j,r)\right|&then&p(i)=p (i)+1\\ if&id_{Layer}(i)<id_{Layer}(j)&then&p(i)=p(i)+1\\ if&d_{i,BS}<d_{j,BS}&then&p(i)=p(i)+1\end{array}  \tag{6}\]  
\(P\) is the score point given to nodes. \(id_{Layer}(i)\) is the id of the layer where the node is situated on. Nodes compute their own delay time to announce being a CH. In this way, nodes that have suitable energy with a higher number of neighbors in the network and are closer to the BS acquire a higher point for being a CH. It should be taken into account that in this protocol we considered the point of all alive nodes equal to zero in the initial round. Also, we applied Equation (6) in each round fornode up to the number of \(N_{nbr}\)(\(i\),\(r\)). After computing the point of being CH, each node is computed according to Equation (7). \[T_{w}(i,r)=\left\{ \begin{array}{cc}\frac{1}{p(i)}\times V_{r}\times T_{2}&ifE_{ ren}(i,r)\geq E_{ave}(i,r)\\ \\ V_{r}\times T_{2}&otherwise\end{array} \right. \tag{7}\]  
In this Equation, \(T_{w}\) is the delay time of the node \(i\).