# Improving Performance of Cluster Heads Selection in DEC Protocol Using K-Means Algorithm for WSN
## 5 Simulation and Evaluation of DEC and DEC-KM Protocols
### Simulation and Evaluation of DEC-KM
#### 5.2.4 Comparison of Clusters and Link Distances between CHs for DEC and DEC-KM  
A comparison of both protocols was performed using computer simulations. Figure 7 shows clustering results for the DEC and the DEC-KM. It is well seen that the DEC-KM protocol divides the network into more compact clusters. Therefore, the link distances between nodes in the cluster are less than for the original protocol. Comparisons of changes in clusters and the link distances are shown in Table 2.  
Figure 6: Results of the implementation of standard DEC-KM protocol: cluster heads are marked as bold black circles, and other nodes are marked as colour rhombus; nodes in the same cluster area are marked with the same colour. Figure 7: Network clustering and node communication in the network: (**a**) in original DEC and (**b**) in DEC-KM; nodes in the same cluster area are marked with the same colour. Results gathered in Table 2 indicate that after K-means clusterisation, two clusters and cluster heads (CH3 and CH8) remained unchanged; five cluster heads (CH5, CH6, CH7, CH9, CH10) remained in the same place, but their clusters have changed, and three new clusters have been created with new cluster heads (CH1, CH2, CH4). The sums of the distances and average distances from the cluster head to the nodes for the original and the modified protocol have been computed and compared in Table 2 for the cluster heads, which remained in the same places, but their clusters have changed. In all cases, K-means clustering improved the network structure. Link distances from the nodes to their cluster heads decreased significantly. The sums of the distances in the cluster areas for the original DEC protocol are less than for the DEC-KM in the 40% to 80% range. Comparisons of the nodes' shortest and longest link distances to their CH are shown in Table 3, and the total and average longest distances are in Table 4. Results in Tables 3 and 4 are related only to the five cluster heads determined from the DEC protocol, which remained in the same place, but their clusters have changed. The node's shortest distances to CH are the same for both protocols, but the sum of the node's most extended distances in DEC-KM is 42% shorter than in the original DEC protocol. As seen in Table 5, the sum of CHs' distances to the base station in DEC-KM did not increase; it is 12% shorter than in the original DEC protocol. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Protocol** & \multicolumn{2}{c}{**SUM of the Longest Distances (m)**} & \multicolumn{2}{c}{**AVE Long Distance (m)**} \\ \hline DEC-KM & 85.85 & 17.17 \\ DEC & 146.42 & 29.28 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Comparison of the total and average longest link distances for DEC and DEC-KM after 5000 rounds. \begin{table}
\begin{tabular}{c c c c c c} \hline \hline \multicolumn{6}{c}{**Link Distances of Nodes to Cluster Head in Each Cluster Area**} \\ \hline \multirow{3}{*}{**CH**} & **Sum in** & **Sum in** & **AVE in DEC,** & **AVE in DEC,** & **DEC-KM** & **DEC-KM** \\  & **DEC (m)** & **DEC-KM (m)** & **(m)** & **(m)** & **DES Dec, \%** \\ \hline
**CH1** & New cluster and new CH are obtained after K-means clusterisation & & & & \\
**CH2** & New cluster and new CH are obtained after K-means clusterisation & & & & \\
**CH3** & The cluster and CH have not been changed & & & & \\
**CH4** & New cluster and new CH are obtained after K-means clusterisation & & & \\
**CH5** & 126.19 & 29.30 & 25.23 & 9.76 & 77\% \\
**CH6** & 106.22 & 22.79 & 17.70 & 7.59 & 80\% \\
**CH7** & 133.64 & 80.32 & 22.27 & 20.08 & 40\% \\
**CH8** & The cluster and CH have not been changed & & & & \\
**CH9** & 104.67 & 33.97 & 17.44 & 8.49 & 69\% \\
**CH10** & 98.30 & 56.73 & 14.04 & 11.34 & 43\% \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Comparison of clusters and link distances to cluster heads for DEC and DEC-KM.