## 4 Proposed Energy Neutral Operation
### Clustering and CH Selection  
Next, we discuss how to form appropriate clusters and select the optimal CH. The proposed clustering and CH selection algorithm is described in Algorithm 2. When the number of clusters is \(K\), let \(\mathcal{N}_{k}\) be the set of nodes in cluster \(k\in\left\{1,2,\cdots,K\right\}\). Without loss of generality, we denote \(i_{k}\) as the CH in cluster \(k\), where \(\exists i_{k}\in\mathcal{N}_{k}\), and \(j_{k}\) as a sensor node in the cluster \(k\), where \(\forall j_{k}\in\mathcal{N}_{k}\setminus\left\{i_{k}\right\}\). The proposed algorithm is based on the well-known K-means clustering algorithm [45]. Thus, the initial \(K\) clusters are determined using the K-means algorithm, and the initial CH in each cluster is determined to be the node closest to the centroid of each cluster. Consequently, the initial cluster and CH are determined by only the distance among sensor nodes without considering the distance between the sensor node and the HAP. However, this distance directly affects the amount of energy harvested, so it is necessary to modify the basic process of the K-means algorithm to make it suitable for the proposed ENO scheme.  
The proposed algorithm mainly consists of two parts, similarly to the K-means algorithm. Firstly, each node reselects the best cluster among the predetermined clusters. After calculating \(R_{ij}\) and \(R_{i_{k}}\) for each CH \(i_{k}\), node \(j\) selects the cluster that provides the highest \(R_{i_{j}}\) among the clusters satisfying \(R_{i_{j}}>R_{i_{k}}\). This step is included so that SWIPT can be performed without decreasing the rate of the predetermined clusters. Thereafter, the best CH is reselected in each cluster. For all nodes in each cluster \(\forall i_{k}\in\left\{\mathcal{N}_{k}\right\}\), the rate of cluster \(k\), \(R_{k}^{\text{swipt}}\), is calculated using Equation (12). Then, the best CH, \(i_{k}^{*}\), is determined as  
\[\begin{split} i_{k}^{*}&=\operatorname*{arg\,max}_{i_ {k}}R_{k}^{\text{swipt}}\\ &=\operatorname*{arg\,max}_{i_{k}}\min\left[\min_{j_{k}\in \mathcal{N}_{k}\setminus\left\{i_{k}\right\}}\left\{R_{i_{k}\text{l}_{k}}^{ \text{swipt}}\right\},R_{i_{k}}^{\text{swipt}}\right]\end{split} \tag{20}\]where \(i_{k}^{*}\) can be found by exhaustive searching with a complexity of \(O(|\mathcal{N}_{k}|)\). This clustering and CH selection algorithm is repeated until all of the cluster sets and CHs are no longer changed. The computational complexity of this algorithm is given by \(O(N^{2})\) because it is based on k-means algorithm, which has a time complexity of \(O(n^{2})\) where \(n\) is the input data size [45].  
```
1:\(\mathcal{N}_{k}\) is the set of nodes in cluster \(k\in\{1,2,\cdots,K\}\)
2:\(i_{k}\) is the CH in the cluster \(k\), \(\exists i_{k}\in\mathcal{N}_{k}\)
3:\(j_{k}\) is a sensor node in the cluster \(k\), \(\forall j_{k}\in\mathcal{N}_{k}\setminus\{i_{k}\}\)
4:Initialize \(\mathcal{N}_{k}\) and \(i_{k}\leftarrow\) K-means algorithm [45]
5:repeat
6:/* Select the best cluster in the network */
7:for each node \(j\in\{\mathcal{N}_{1}\cup\cdots\cup\mathcal{N}_{K}\}\)do
8:for each CH \(i_{k}\)do
9: Determine \(R_{i_{k}}\) from Equation (3)
10: Determine \(R_{i_{k}}\) from Equation (5)
11:endfor
12:if\(\exists i_{k}\in\{i_{k}|R_{i_{k}j}>R_{i_{k}}\}\
eq\emptyset\)then
13:\(j\)'s cluster \(\leftarrow\arg_{k}\max\{R_{i_{k}j}\}\) for \(\exists i_{k}\in\{i_{k}|R_{i_{k}j}>R_{i_{k}}\}\)
14:else
15:\(j\)'s cluster \(\leftarrow\arg_{k}\max\{R_{i_{k}j}\}\) for \(\forall i_{k}\)
16:endif
17:endfor
18:/* Select the best CH in each cluster */
19:for each cluster \(k\)do
20:for each node \(i_{k}\in\{\mathcal{N}_{k}\}\)do
21: Calculate \(R_{k}^{\text{swipt}}\) from Equation (12)
22:endfor
23:CH \(i_{k}^{*}\leftarrow\arg_{i_{k}}\max\{R_{k}^{\text{swipt}}\}\) from Equation (20)
24:endfor
25:until \(\forall\mathcal{N}_{k}\) and \(\forall i_{k}\) are no longer changed
```  
**Algorithm 2**Clustering and CH selection