# FTUC: A Flooding Tree Uneven Clustering Protocol for a Wireless Sensor Network
## 5 FTUC Algorithm
### Building Cluster Phase  
Once the minimum and maximum values are distributed in the network, the algorithm starts to create the unequal clusters. This process begins by randomly electing tentative cluster heads, and all nodes calculate their weight value and competition radius. Secondly, the tentative cluster heads choose the node with the biggest weight value as the final cluster head in its own competition radius range. Finally, the final CHs broadcast a 'join cluster' message to build their own clusters, and then send the'search cluster' message in order to build the inter-cluster route. The clustering algorithm is executed as follows:  
_Step 1: calculate weight value and competition radius_  
After receiving \(\mathrm{D_{max}}\) and \(\mathrm{D_{min}}\) values from the BS, each node uses Equation (8) to calculate its competition radius \(\mathrm{R_{competition}}\). \[\mathrm{R_{competition}}=\left(1-\mathrm{C}\frac{\mathrm{D_{max}}-\mathrm{ Dist}(\mathrm{S_{i}},\mathrm{BS})}{\mathrm{D_{max}}-\mathrm{D_{min}}}\right) \mathrm{R_{C}} \tag{8}\]  
Figure 3: Flooding tree algorithm phases to build a tree type sub-network. The flooding phase enables one to create a unique and fast path between all nodes in the network. (**a**) Network initialization; (**b**) Running flooding tree algorithm; (**c**) Build tree type network; (**d**) Network finished. where Dist(S\({}_{i}\),BS) is the distance between the current node and the base station, R\({}_{c}\) is the communication range of the radio front-end, and C is a control parameter belonging to [0, 1]. This parameter permits one to control the size of the created cluster depending on the distance to the BS. For example, if C is set to \(\frac{1}{4}\), R\({}_{competition}\) varies from \(\frac{3}{4}\)R\({}_{c}\) to R\({}_{c}\) according to the distance between S\({}_{i}\) and the base station. In order to evenly distribute the CHs, we propose the'reference position circle' R\({}_{i}\), evaluated as:  
\[\mathrm{R_{i}}=\left|\sin\frac{\mathrm{Dist(S_{i},BS)}\times 2\pi}{\mathrm{R_{0}}}\right| \tag{9}\]  
where R\({}_{0}\) is the control parameter of the conferenced position circles. As R\({}_{i}\) divides the total area of sensing into several zones, it should be chosen according to M and R\({}_{c}\). The trade-off is made since all the nodes should be able to communicate with a CH near a position reference circle, and the number of circles should not be too high to evenly distribute the CHs in the area. At this stage, each node calculates its weight value (W0):  
\[\mathrm{W0}=\mathrm{C1}\times\mathrm{R_{i}}+\mathrm{C2}\times\mathrm{E_{c}} \tag{10}\]  
where C1 and C2 are control parameters that enable one to make a trade-off between the node residual energy, E\({}_{c}\), and its distance to the'reference position circle'. For example, if R\({}_{0}\) in Equation (9) is set to 200 m, when a node is at Dist(S\({}_{i}\),BS) = 50 m or Dist(S\({}_{i}\),BS) = 150 m from the BS, R\({}_{i}\) is at its maximum value of 1. Considering nodes with the same residual energy, the closest node to R\({}_{i}\) will have a greater chance to be elected as a CH. _Step 2: Randomly Generate Tentative CH_  
At this step, each node randomly generates a number Q, and if Q < T, the node is set as a tentative CH. The threshold T enables one to control the number of tentative CHs in this phase. For example, if T = 0.08, then 100 nodes will elect eight tentative CHs. _Step 3: Final CHs choice_  
Each tentative CH then broadcasts an 'id message' in its competition radius R\({}_{competition}\), and when regular nodes receive this message, they send back their own W0 value. Afterward, the tentative CH compares each received W0, including the one from itself, and chooses the node with the biggest value as the final CH, denoted as fCHi for cluster i. Finally, the elected fCHs broadcast the 'join cluster message' in their zone of influence (i.e., its competition radius).