# A Cluster-Based Dual-Adaptive Topology Control Approach in Wireless Sensor Networks
## 3 The Improved Clustering Scheme
### Cluster Formation
#### 3.2.3 Selecting SCHs
The value of \(\sigma_{k,j,i}\) is estimated by the following formula:

\[\sigma_{k,j,i}=\sqrt{\frac{\left(d_{k,i}-d_{k,j,i}\right)^{2}+\left(d_{k,j}-d _{k,j,i}\right)^{2}+\left(d_{i,j}-d_{k,j,i}\right)^{2}}{3}} \tag{10}\]

In Equation (10), \(d_{k,j,i}\) denotes the average value of \(d_{k,i}\), \(d_{k,j}\), and \(d_{i,j}\). Our cluster member association and FCH selection process is described in Algorithm 4. In Algorithm 4, a non-CH node first initializes the flag variable of each neighboring MCH as _\"unrequested\"_ (see lines 1-3), and then selects the closest MCH with it from all the neighboring MCHs with _\"unrequested\"_ and attempts to associate itself with this closest MCH by sending the \"membership request message\" (see lines 4-8). If this non-CH node does not find its _ID_ in the \"membership list message\", it resends its \"membership request message\" to the next closest MCH. This process will be repeated until this non-CH node is admitted by a MCH or attempts the maximum number of retransmissions (see lines 9-16). Upon receiving the first \"membership request message\" from any non-CH node, the MCH computes FCH eligibility metric for this non-CH node according to the Equation (9), adds the _ID_ of this non-CH node to the \"membership list message\", and sets a fixed duration of time \(\phi\) to allow other non-CH nodes to send their \"membership request messages\" (see lines 17-21). ```
Run at any non-CH node (e.g., \(w\))  Input: the hello messages of all neighbors  Output: the membership request message
1. for each entry (\(ID_{w}\), \(d_{w,w}\)) in \(L_{w,w}\)do
2. if the state variable \(s_{u}\) is \"_decided MCH_\" then initialize the flag variable \(f_{u}\) as \"_unrequested_\"
3. endfor
4. \(d_{min}\) = _maximum number_; \(ID_{mch}\) = _maximum number_
5. for each entry (\(ID_{w}\), \(d_{w,w}\)) in \(L_{w,w}\)do
6. if (\(f_{u}\) = \"_unrequested_\") and ((\(d_{w,w}<d_{min}\)) or (\(d_{w,w}=d_{min}\) && \(ID_{w}<ID_{mch}\))) then {\(d_{min}\) = \(d_{w,w}\); \(ID_{mch}\) = \(ID_{m}\)}
7. endfor
8. Send the \"membership request message\" to the neighboring MCH with \(ID_{mch}\)
9. if receive the \"membership list message\" from the neighboring MCH with \(ID_{mch}\) (e.g., \(y\)) then
10. if find that its \(ID\) (i.e., \(w\)'s \(ID\)) is not in the \"membership list message\" then
11. if not more than the given maximum number of resending attempts then
12. \(f_{y}\) = \"_requested_\"
13. Go to step 4
14. endif
15. endif
16. endif Run at a MCH node (e.g., \(u\)) which has a SCH node (e.g., \(v\))  Input: the hello messages of all neighbors  Output: the membership list message
17. if receive the first \"membership request message\" from any non-CH node (e.g., \(w\)) then
18. Compute node \(w\)'s FCH eligibility metric \(FM_{w,w}\) according to the Formula (9)
19. \(FM_{mxt}\) = \(FM_{w,w,i}\); \(ID_{fib}\) = \(ID_{w}\)
20. Add \(ID_{w}\) to the membership list message
21. Set the timer \(t_{\phi}\) as \(\phi\)
22. while the timer \(t_{\phi}\) does not expire do
23. if receive the \"membership request message\" from any non-CH node (e.g., \(x\)) then
24. if the number of cluster members is less than the threshold then
25. Add \(ID_{x}\) to the membership list message
26. Compute node \(x\)'s FCH eligibility metric \(FM_{x,w,i}\) according to the Formula (9)
27. if (\(FM_{mxt}\) < \(FM_{x,w,i}\)) or (\(FM_{mxt}\) == \(FM_{x,w,i}\) && \(ID_{x}<ID_{fib}\)) then {\(FM_{mxt}\) = \(FM_{x,w,i}\); \(ID_{fib}\) = \(ID_{x}\)}
28. endif
29. endwhile
30. Declare the node with \(ID_{fib}\) as the FCH through adding it to the membership list message
32. Design a TDMA schedule and add it to the membership list message
33. Broadcast the \"membership list message\" to its neighbors within the cluster radius
34. elseif a new non-CH wants to join a given MCH and the number of cluster members is less than the threshold then
35. Update the TDMA schedule to include this node's \(ID\) and add it to the \"membership list message\"
36.