## 4 The Proposed Algorithm-TCEB
### Intra-Cluster Topology Construction
After broadcasting the _INVITATION_ message including the ID and \(u_{i}\) by the cluster-head, the non-cluster-head node will perform the next action promptly depending on how many _INVITATION_ messages it has gotten. Considering the case that the non-cluster-head node may have received a number of _INVITATION_ messages from the multiple cluster-heads, various strategies are adopted according to the value of \(u_{i}\) to make all of the clusters load balance as much as possible. Once the non-cluster-head node receives only one _INVITATION_ message, it naturally becomes the cluster member of the cluster-head which sends such message previously and replies the _ACK_ message. If the non-cluster-head node receives more than one _INVITATION_ message, then it chooses to be the cluster member of the cluster-head with the largest \(u_{i}\) and sends back the reply message of _ACK_. Otherwise, the non-cluster-head node waits to join a cluster with multi-hop communication method. Specially, once the non-cluster-head node receives multiple _INVITATION_ messages from different cluster-heads with the same largest \(u_{i}\), then it chooses one of the clusters randomly to join while answering the corresponding _ACK_ back. During such process, we notice that non-cluster-heads may not have received any messages from any cluster-head. To achieve the goal of minimizing the energy consumption of the network, it is necessary to design a strategy on how to select the next hop neighbor node to form the best transmission path. Consequently, the relay node will be selected in terms of the communication cost to make sure that kind of node joins into one of the clusters. The mechanism for selecting the relay node can be defined as:  
\[p\left(i,j\right)=\gamma\frac{E_{r}(j)}{E_{\mathrm{cons}}(i,j)}+\left(1-\gamma \right)\left(R_{\mathrm{link}}\left(i,j\right)+\frac{1}{pd_{\mathrm{loss}}(j) }\right) \tag{16}\]  
where \(E_{r}(j)\) is the residual of the node \(j\), \(E_{\mathrm{cons}}(i,j)\) is the total energy consumption on communication between the node \(i\) and \(j\), which refers to both energy dissipation when the node \(i\) sends the message and the node \(j\) receives the message. \(R_{link}(i,j)\) and \(pd_{loss}(j)\) are the link reliability between the node \(i\) and \(j\) and the packet loss rate of the node \(j\), respectively, and \(\gamma\) is the adjustment factor, which satisfies \(0<\gamma<1\). Equation (16) reflects the probability that the non-cluster-head node \(i\) chooses its one-hop neighbor node \(j\) as the relay node to communicate with the cluster-head. It can be easily seen from Equation (16) that the more the residual energy of the node \(j\) and the lower the cost between both communication nodes, the easier the node \(j\) to be selected as the relay node. Simultaneously, the higher the link reliability and the smaller the packet loss rate, the easier the node \(j\) to be the relay node as well. Therefore, to obtain an optimum relay node during the intra-cluster topology construction, we cannot merely look at a parameter or a part of the parameters in this strategy, but take care the trade-off between the various parameters. At this time, \(\gamma\) is the key factor for adjusting the trade-off to select the optimum relay nodes to build better local topology. Algorithm 2 gives the pseudo-code of intra-cluster topology construction. The detailed steps for intra-cluster topology construction are presented as follows. * **Step 1. ** The cluster-head broadcasts the _INVITATION_ message including its ID and \(u_{i}\), and set a _timeout_ as well. * **Step 2. ** Once the non-cluster-head can receive the _INVITATION_ message from the cluster-head within _timeout_, go to **Step 3**, otherwise, perform **Step 5**. * **Step 3. ** Once the non-cluster-head node receives various _INVITATION_ messages from multiple cluster-heads, it will choose to join the cluster which has the cluster-head with the largest \(u_{i}\).