# Clustering-Based Channel Allocation Method for Mitigating Inter-WBAN Interference
## 4 Cluster-Based Channel Allocation Method
### Base Module  
The number of channels available for a WBAN is limited. Therefore, to reduce the total interference among WBANs, we should allocate channels in a way that the WBANs using the same channel are located as far away as possible. To achieve the goal, in the base module, a cloud server constructs an interference relationship graph \(G\) using the location information reported by the WBANs in \(\mathcal{S}\). Then, the cloud server partitions the graph using the Louvain algorithm to maximize the modularity of the graph. We denote the resulting set of clusters for a graph \(G=(N,E,W)\) as \(C=\{C_{1},\cdots,C_{|C|}\}\). A cluster \(C_{i}\) is composed of the WBANs \(C_{i}=\{v_{i,1},\cdots,v_{i,|C_{i}|}\}\), where \(v_{i,j}\) represents a WBAN \(j\) belonging to a cluster \(i\).  
To determine a channel for each WBAN in each cluster \(C_{i}\), we consider the interference relationship subgraph \(G_{C_{i}}\) induced by the WBANs in \(C_{i}\). We assign a color to each WBAN \(v_{i,j}\) in \(C_{i}\) by applying a graph coloring algorithm to \(G_{C_{i}}\). We denote the minimum number of colors required to color the WBANs in \(C_{i}\) as \(n_{c}^{i}\). We also denote the set of required colors for \(G_{C_{i}}\) as \(O_{i}=\{1,\cdots,n_{c}^{i}\}\) and assume that colors are assigned from one sequentially. If the number of required colors is not larger than the number of available channels (i.e., \(n_{c}^{i}\leq|K|\)) and a color \(q\) is assigned to a WBAN \(v_{i,j}\), \(q\) becomes the channel number allocated to \(v_{i,j}\). However, if \(n_{c}^{i}>|K|\), the same channel is inevitably assigned to multiple WBANs in \(C_{i}\). In this case, a cloud server allocates a channel to \(v_{i,j}\in C_{i}\) as follows. If a color \(q\) is assigned to a WBAN \(v_{i,j}\) and \(q\leq|K|\), a cloud server assigns the channel \(q\) to \(v_{i,j}\). In contrast, if \(|K|<q\leq n_{c}^{i}\), the channel number to be allocated to the WBAN whose color is \(q\) is randomly determined from \([1,|K|]\) according to the Uniform distribution.  
After assigning channels to the WBANs in \(C_{i}\), the base module determines a center position of the cluster as follows.  
\[\vec{p}(C_{i})=\frac{1}{|C_{i}|}\sum_{v_{i,j}\in C_{i}}\vec{p}(v_{i,j}), \tag{7}\]  
where \(\vec{p}(v_{i,j})\) is the vector that represents the location of a WBAN \(v_{i,j}\), and \(\vec{p}(C_{i})\) represents the position of the center point in \(C_{i}\). We summarize the base module in Algorithm 1.  
```
1:Input: a graph \(G=(N,E,W)\)
2:Output: a channel allocation vector \(\alpha\)
3:Given a graph \(G=(N,E,W)\):
4: Make clusters using Louvain algorithm and get \(C=\{C_{1},\cdots,C_{|C|}\}\).
5:\(i=0\)
6:while\(i\leq|C|\)do
7: Color the WBANs in \(G_{C_{i}}\) by using a graph coloring algorithm.
8: Get the number \(n_{c}^{i}\) of colors required to color all the WBANs in \(C_{i}\).
9:\(j=0\)
10:while\(j\leq|C_{i}|\)do
11: Get the color \(q\) assigned to \(v_{i,j}\).
12:if\(q\leq|K|\)then
13: Allocate the channel \(q\) to a WBAN \(v_{i,j}\).
14:else
15: Randomly select a channel \(q^{\prime}\) from \([1,|K|]\)
16: Allocate \(q^{\prime}\) to \(v_{i,j}\).
17:\(j++\)
18: Get a center point of \(C_{i}\): \(\vec{p}(C_{i})=\frac{1}{|C_{i}|}\sum_{v_{i,j}\in C_{i}}\vec{p}(v_{i,j})\)
19:\(i++\)
```  
**Algorithm 1** Base Module  
The edge between two WBANs \(i\) and \(j\) exists only when \(d_{i,j}<\delta_{d}\). Our base module clusters the WBANs according to the concentration level of the edges within the clusters.  
Thus, the WBANs in the same cluster will interfere with each other if they use the same channel. Therefore, by allocating different channels to the WBANs in the same cluster as much as possible, the base module mitigates the inter-WBAN interference.