## 4 Our Proposed Algorithm
### A Novel Data-Gathering Scheme with Joint Routing and CS  
Obviously, according to the analysis, the network load in hybrid CS is unbalanced. Specifically, sensor nodes near the sink node will consume more energy than those far from the sink node because of forwarding data more times. This results in sensor nodes near the sink dying earlier. However, [23] does not consider the total network costs for each random projection. To avoid the drawbacks, one can leverage the advantages of the algorithms; in this section, we present our data-gathering strategy combining joint routing and CS. Firstly, randomly choose \(M\) projection nodes in the network with probability \(\frac{M}{N}\), which follows [23]. In the CS theory, the sink node needs \(M\) measurements to reconstruct the original data. Therefore, these \(M\) projection nodes will be selected as the gathering node, defined as \(g_{1},g_{2},\ldots,g_{m}\), to collect one random measurement \(y_{i}\), and transmit \(y_{i}\) to the sink node. Then, distribute non-zero elements in each row of measurement matrix \(\Phi\) as uniformly as possible to guarantee the sparse features of the measurement matrix; the number of non-zero elements in each row should equal to \(\left\lceil\frac{N}{M}\right\rceil\), which is related to Algorithm 3's step 1. Additionally, each column of measurement matrix represents a sensor node, so if a column of the matrix has full zero elements, the data from its special sensor node should be thrown away. \(\phi_{i}\), the column vector of measurement matrix \(\Phi\) is required to store each sensor node memory in advance. Now, an example of measurement matrix is given in Equation (18), where \(M=5\), and \(N=10\). Secondly, each row \(\phi_{S1}\) of measurement matrix \(\Phi\) corresponds to one projection node. However, the number of each row coefficient is \(N\), which is assigned to the size of network. \(\phi_{ij}\
eq 0\) indicates that \(j\)th candidate nodes belong to the \(i\)th projection node's. Here, this subsection corresponds to step 3 in Algorithm 3. \[\Phi= \begin{bmatrix}0&0&0&\phi_{1,4}&0&\phi_{1,6}&0&0&0\\ \phi_{2,1}&0&\phi_{2,3}&0&0&0&0&0&0\\ 0&0&0&0&\phi_{3,5}&0&0&\phi_{3,8}&0&0\\ 0&0&0&0&0&\phi_{4,7}&0&0&\phi_{4,10}\\ 0&\phi_{5,2}&0&0&0&0&0&\phi_{5,9}&0\end{bmatrix}  \tag{18}\]  
Subsequently, we set up the routing, which is from the offspring sensor nodes to the projection nodes and the projection nodes to the sink node, respectively. Based on the MST algorithm, access all candidate sensor nodes of a given projection node. In the first stage, the projection node is considered one root node tree. In the step 4 initialization stage in Algorithm 3, \(Tree_{i}\) is assigned by \(i\), and the temporary variable \(temp\) also yields \(i\). Then steps 5-12 use the MST algorithm to construct the tree, adding the candidate nodes step by step. If \(temp\) is not empty, step 6 deletes the top node of the \(temp\) queue and puts its neighbor node in the \(Tree\) and \(temp\). The next step is to delete them from \(Can_{i}\) if they belong to \(Can_{i}\). Note that these candidate nodes must be directly connected to the parent node by a single hop. If there are still some candidate nodes not involved in the tree, the \(Dijkstra\) algorithm [40] is proposed, aiming to find the shortest path from the residual nodes to the tree (steps 14-19), and we add the residual candidate nodes (steps 20-22). Finally, this loop of 13-26 lines will repeat until \(Can_{i}\) is empty. The modified ant colony routing technique is utilized to transmit packets of projection nodes to the sink node, namely step 27 of Algorithm 3. Consequently, Algorithm 3 terminates by generating the optimal routing between the projection nodes and the sink node, and an \(M\) routing tree from the projection nodes to their own candidate nodes. Our novel algorithm (Algorithm 3) is shown in more detail.