# Improved Performance on Wireless Sensors Network Using Multi-Channel Clustering Hierarchy
## 2 Multi-Channel Clustering Hierarchy (MCCH)
### The Process of Forming a WSN Channel  
If the distance between the member and CH nodes has been obtained, the next step is the clustering analysis process. Single linkage is a clustering technique that produces a series of decreasing numbers of clusters at each stage. The clusters contained in each stage are obtained from the previous stage by combining two clusters that display similarities. This technique is carried out using two methods, namely matrix theory and graph theory. This single linkage does not require a specific number of clusters in the grouping process, so we do not need to determine the number of clusters that will be formed at an early stage. However, for certain cases it is possible to determine the number of clusters  
Using this technique, so that when grouping occurs there will be hierarchical cuts at certain points according to the initial conditions of the grouping. The following is a solution algorithm using Single linkage. 1. contains a single entity and a symmetric matrix of the distance (similarities)
2. Find the distance matrix for the closest (most similar) cluster pair. For example, the distance between clusters U and V that is most similar is d u v.
3. Merge the newly formed cluster U and V cluster labels with (UV). Then, update the entries in the distance matrix in the following way:
4. Delete rows and columns corresponding to clusters U and V.
5. Add rows and columns giving the distances between the cluster (UV) and the remaining clusters. 6. Repeat steps 2 and 3 (N - 1) times. All objects will be in a single cluster after the algorithm ends. Note the identity of the merged cluster and the level (distance or similarity) at which the merger occurs. \[\text{d}\;(\text{h},\;\text{i},\;\text{j})\;\text{k}=\text{min}\;(\text{d}\; \text{h}\text{k},\;\text{d}\;\text{i}\text{k},\;\text{d}\;\text{j}\text{k}). \tag{3}\]  
Notes:  
d = Channel or CH,  
h = node member,  
I = node member,J = node member. ```
for k = 1:N  for i = 1:size(clustering_channel(k).node,2) \(p\) = clustering_channel(k).node(i); \(\text{hac(k).ch(i).id = node(p).id;}\) for j = 1:size(clustering_channel(k).node,2) \(\text{hac(k).ch(i).d(j).id = clustering_channel(k).node(j);}\) end end [\(\sim\),index] = sortrows ([hac(k).ch(i).d.dis]. '); \(\text{hac(k).ch(i).d= hac(k).ch(i).d(index);}\) clear index end iter = 0; \(\text{x = zeros()}\); for i = 1: size(node,2) if node(i).cent end end y = pdist(x); \(\text{Y = squareform(y)}\); \(\text{z = linkage(y)}\); figure() dendrogram(z) title(strcat(Channel-', num2 str(k))) D = 0; for i = 1:size(z,1) D = D + z(i,3); end HAC(k).distance = D; \(\text{sc = size(clustering_channel(k).node,2)}\); F = 0; for i = 1:size(z,1) n1 = z(i,1); n2 = z(i,2); if n1 \(<\) sc &# n2 \(<\)= sc F = F + 1; end end I = inconsistent(z); loss = 0; for i = 1:size(I,1) loss = loss + I(i,4); end end
```  
**Algorithm 3**Calculation of the distance between each node and cluster head  
Figure 5 describes the process of grouping member nodes and cluster heads using a single linkage approach by looking for proximity to the cluster head [36]. Table 5 is the final algorithm which is the grouping process between the four cluster heads and cluster members. Figure 6 is a single channel that exists in the current WSN technology. Each node will send data directly to the server/sink which results in a lot of data queues and data density, therefore a WSN protocol with the MCCH method has been developed which can divide the protocol channel so that it can reduce traffic congestion in WSN.