# On Connectivity and Energy Efficiency for Sleeping-Schedule-Based Wireless Sensor Networks
## 3 Connectivity and Energy Efficiency Algorithm
### The New Connectivity and Energy Efficiency Network Algorithm
```
Initialize parameters including \(K\), \(N\), \(R\), and \(S\) Repeat  Update list of neighbor node \(M_{i}\) If\(M_{i}\cap M_{i}\
eq\phi\), Then /* Determine which node for waking up by its energy and distance to node \(i\) */ \(W_{i}\leftarrow-\infty\) \(j_{\mathrm{SEL}}\gets 0\) /* Node selected to wake up */ While\(j\in M_{\omega}\) Do \(D_{ij}\leftarrow\left|T_{i}-T_{j}\right|V\) \(w_{ij}\leftarrow\omega_{1}E_{j}+\omega_{2}D_{ij}\) If\(w_{ij}>W_{i}\) Then \(W_{i}\gets w_{ij}\) /* Search for node \(j\) with the biggest \(W_{i}\) */ \(j_{\mathrm{SEL}}\gets j\) End If End While Wake up the selected node \(j\) \(M_{s}\gets M_{s}-\left\{j_{\mathrm{SEL}}\right\}\) \(M_{w}\gets M_{\omega}+\left\{j_{\mathrm{SEL}}\right\}\) End If \(T_{i}\gets T_{i}+\Delta T\) /* Go to next time slot */ \(N_{i}\leftarrow\mathrm{card}(M_{i})\) Until\(N_{i}\geq K\)
```  
**Algorithm 1** Connectivity and Energy Efficiency (CEE) Algorithm. The new network connectivity and energy efficiency algorithm is described in detail below. Set up the number of sensor nodes in the monitoring area as \(N\), their collection is \(M=\left\{1,2,3,\ldots,N\right\}\). The number of nodes in working condition is \(N_{w}\), its collection is \(M_{w}\), then there are \((N-N_{w})\) nodes in the sleeping state, its collection is \(M_{s}\). The above collections meet \(M_{w}\subset M,M_{s}\subset M\), and \(M_{w}+M_{s}=M\). For \(\forall i\in M_{w}\), the collection is composed of its neighbor nodes as \(M_{i}\), moreover the number of elements in the \(M_{i}\) is \(N_{i}\leq K\). In Step 1, initialize and calculate the parameters. According to the previous section on the derived formula, calculate the connectivity \(K\) and the connectivity probability \(P_{r}\) as the output, and the number of nodes \(N\), the node communication radius \(R\), and the monitoring area \(S\) are the inputs. According to Equation (4), when the sprinkling area \(S\) and the number of node \(N\) are known, the communication radius \(R\) of sensor nodes under the maximum network connectivity probability can be calculated. Given the sprinkling area \(S\) of the sensor and the communication radius \(R\) of the sensor node, then, according to Equation (6), the number of sensor nodes \(N\) under the maximum network connectivity probability can be calculated. Connectivity \(K\) of wireless sensor network nodes is subject to binomial distribution, denoted by \(B(K\),\(P)\), among \(P=\frac{\pi R^{2}}{S}\), \(P\) is the probability that the communication coverage area of the node occupies the total area. Within a certain area, if we want to increase the probability of the network connectivity \(K\), then the number of sensor nodes \(N\) should be increased or the communication radius \(R\) of sensor nodes should be increased. In Step 2, update the list of neighbor nodes' information. In a particular time \(T_{i}\), for any node \(i\in M_{w}\), which send a single hop broadcast, establish communication with all of its neighbor nodes \(M_{i}\), require them to send their own information to the node \(I\), such as the identity of the node, self-state information (waking or sleeping), the sent timestamp \(T_{p}\), the residual energy \(E_{j}\), and so on. Node \(i\) in \(M_{i}\) receives the related information from all the other nodes, updates the node information list immediately, and then filters which nodes in line meet the requirements of node communication. It is similar to how routers update the routing table in the computer network. In Step 3, achieve network connectivity \(K\). If the number of neighbor nodes of node \(i\) reaches \(K\), this shows network connectivity can be achieved and the networking ends. If the number of working neighbor nodes of node \(i\) is less than \(K\), a certain number of neighbor nodes must be awakened to guarantee the network connectivity reaches \(K\).