Multilevel Hierarchical Kernel Spectral Clustering for Real-Life Large Scale Complex Networks

Kernel spectral clustering corresponds to a weighted kernel principal component analysis problem in a constrained optimization framework. The primal formulation leads to an eigen-decomposition of a centered Laplacian matrix at the dual level. The dual formulation allows to build a model on a representative subgraph of the large scale network in the training phase and the model parameters are estimated in the validation stage. The KSC model has a powerful out-of-sample extension property which allows cluster affiliation for the unseen nodes of the big data network. In this paper we exploit the structure of the projections in the eigenspace during the validation stage to automatically determine a set of increasing distance thresholds. We use these distance thresholds in the test phase to obtain multiple levels of hierarchy for the large scale network. The hierarchical structure in the network is determined in a bottom-up fashion. We empirically showcase that real-world networks have multilevel hierarchical organization which cannot be detected efficiently by several state-of-the-art large scale hierarchical community detection techniques like the Louvain, OSLOM and Infomap methods. We show that a major advantage of our proposed approach is the ability to locate good quality clusters at both the finer and coarser levels of hierarchy using internal cluster quality metrics on 7 real-life networks.


Introduction
Large scale complex networks are ubiquitous in the modern era. Their presence spans a wide range of domains including social networks, trust networks, biological networks, collaboration networks, financial networks etc. A complex network can be represented as a graph G~(V ,E) where V represent the vertices or nodes and E represents the edges or interaction between these nodes in this network. Many real-life complex networks are scalefree [1], follow the power law [2] and exhibit community like structure. By community like structure one means that nodes within one community are densely connected to each other and sparsely connected to nodes outside that community. The large scale network consists of several such communities. This problem of community detection in graphs has received wide attention from several perspectives [3][4][5][6][7][8][9][10][11][12][13][14].
The community structure exhibited by the real world complex networks often have an inherent hierarchical organization. This suggests that there should be multiple levels of hierarchy in these real-life networks with good quality clusters at each level. In other words, there exist meaningful communities at refined as well as coarser levels of granularity in this multilevel hierarchical system of the real-life networks.
A state-of-the-art hierarchical community detection technique for large scale networks is the Louvain method [15]. It uses a popular quality function namely modularity (Q) [3,5,6,16] for locating modular structures in the network in a hierarchical fashion. Modularity measures the difference between a given partition of a network and the expectation of the same partition for a random network. By optimizing modularity, they obtain the modular structures in the network. However, it suffers from a drawback namely the resolution limit problem [17][18][19]. The issue of resolution limit arises because the optimization of modularity beyond a certain resolution is unable to identify modules even as distinct as cliques which are completely disconnected from the rest of the network. This is because modularity fixes a global resolution to identify modules which works for some networks but not others.
Recently the authors of [20] show that methods trying to use variants of modularity to overcome the resolution limit problem, still suffer from the resolution limit. They propose an alternative algorithm namely OSLOM [21] to avoid the issue of resolution. However, in our experiments we observe that OSLOM works well for benchmark synthetic networks [4] but in case of real-life networks it is unable to detect quality coarse clusters. We also evaluate another state-of-the-art hierarchical community detection technique called the Infomap method [7]. The Infomap method uses an information theoretic approach to hierarchical community detection. It uses the probability flow of random walks as a substitute for information flow in real-life networks. It then fragments the network into modules by compressing a description of the probability flow.
Spectral clustering methods [10][11][12][13][14] belong to the family of unsupervised learning algorithms where clustering information is obtained by the eigen-decomposition of the Laplacian matrix derived from the affinity matrix (S) for the given data. A drawback of these methods is the construction of the large affinity matrix for the entire data which limits the feasibility of the approach to small sized data. To overcome this problem, a kernel spectral clustering (KSC) formulation based on weighted kernel principal component analysis (kPCA) in a primal-dual framework was proposed in [22]. The weighted kPCA problem is formulated in the primal in the context of least squares support vector machines [23] which results in eigen-decomposition of a centered Laplacian matrix in the dual. As a result, a clustering model is obtained in the dual. This model is build on a subset of the original data and has a powerful out-ofsample extension property. This property allows cluster affiliation for unseen data.
The KSC method was applied for community detection in graphs by [24]. However, their subset and model selection approach was computationally expensive and memory inefficient. Recently, the KSC method was extended for big data networks in [25]. The method works by building a model on a representative subgraph of the large scale network. This subgraph is obtained by the fast and unique representative subset (FURS) selection technique as proposed in [26]. During the model selection stage, the model parameters are estimated along with determining the number of clusters k in the network. A self-tuned KSC model for big data networks was proposed in [27]. The major advantage of the KSC method is that it creates a model which has a powerful out-of-sample extensions property. Using this property, we can infer community affiliation for unseen nodes of the whole network.
In [28], the authors used multiple scales of the kernel parameter s to determine the hierarchies in the data using KSC approach. However, in this approach the clustering model is trained for different values of (k,s) and evaluated for the entire dataset using the out-of-sample extension property. Then, a map is created to match the clusters at two levels of hierarchy. As stated by the authors in [28], during a merge there might be some data points of the merging clusters that go into a non-merging cluster which is then forced to join the merging cluster of the majority. In this paper, we overcome this problem and generate a natural hierarchical organization of the large scale network in an agglomerative fashion.
The purpose of hierarchical community detection is to automatically locate multiple levels of granularity in the network with meaningful clusters at each level. The KSC method has been used effectively to obtain flat partitioning in real-world networks [24,25,27]. In this paper, we exploit the structure of the eigenprojections derived from the KSC model. The projections of the validation set nodes in the eigenspace is used to create an iterative set of affinity matrices resulting in a set of increasing distance thresholds ( ). Since the validation set of nodes is a representative subset of the large scale network [26], we use these distance thresholds (t i [ ) on the projections of the entire network obtained as a result of the out-of-sample extension property of the KSC model. These distance thresholds, when applied in an iterative manner, provide a multilevel hierarchical organization for the entire network in a bottom-up fashion. We show that our proposed approach is able to discover good quality coarse as well as refined clusters for real-life networks.
There are some methods that optimize weighted graph cut objectives [29][30][31] to provide multilevel clustering for the large scale network. However, these methods suffer from the problem of determining the right value of k which is user defined. In realworld networks the value of k is not known beforehand. So in our experiments, we evaluate the proposed multilevel hierarchical kernel spectral clustering (MH-KSC) algorithm against the Louvain, Infomap and OSLOM methods. These methods automatically determine the number of clusters (k) at each level of hierarchy. Figure 1 provides an overview of steps involved in the MH-KSC algorithm and Figure 2 depicts the result of our proposed MH-KSC approach on email network (Enron).
In all our experiments we consider unweighted and undirected networks. All the experiments were performed on a machine with 12 Gb RAM, 2.4 GHz Intel Xeon processor. The maximum size of the kernel matrix that is allowed to be stored in the memory of our PC is 10,000610,000. Thus, the maximum cardinality of our training and validation sets can be 10,000. We use 15% of the total nodes as size of training and validation set (if less than 10,000) based on experimental findings in [32]. We make use of the procedure provided in [25] to divide the data into chunks in order to extend our proposed approach to large scale networks. There are several steps in the proposed methodology which can be implemented on a distributed environment. We describe this in detail later.

Kernel Spectral Clustering (KSC) Method
We first summarize the notations used in the paper.
given by x i~A ( : ,i).
6. maxk is the maximum number of eigenvectors that we want to evaluate. 7. K( : , : ) represents the positive definite kernel function. 8. The matrix S represents the affinity or similarity matrix. 9. P represents the latent variable matrix containing the eigenprojections. 10. h represents the h th level of hierarchy and maxh stands for the coarsest level of hierarchy. 11. Set C comprises multilevel hierarchical clustering information. 12. Coarsest level of hierarchy corresponds to fine grained clusters and finer levels of hierarchy correspond to coarse clusters.

KSC methodology
Given a graph G, we use the fast and unique representative subset (FURS) selection [26] technique to obtain training and validation set of nodes V tr and V valid . FURS [26] is a deterministic subgraph selection technique where nodes with high degree centrality are greedily selected from most or all the communities in the network. Nodes with high degree centrality are usually located  at the center, away from the periphery of the network and can better capture the inherent community structure. Since our goal is a locate multilevel hierarchical clustering in the large scale network, it is essential that the training and validation set are representative of the underlying community structure of the network. A detailed description of the FURS approach and its comparison with other state-of-the-art subset selection techniques is provided in [26].
We use 15% of the total nodes as size of training and validation set (if less than 10,000 otherwise 10,000 nodes) based on experimental findings in [32]. Firstly, we apply FURS to obtain the training set of nodes V tr . Once these nodes are selected in the training set we remove these nodes from the network but maintain the topology (degree distribution) of the network. We then apply FURS again to obtain the validation set of nodes V valid . Thus, both these sets V tr and V valid are selected such that they retain the inherent community structure of the large scale network. We then use the entire large scale network as the test set V test .
For V tr training nodes the dataset is given by The adjacency list x i can efficiently be stored into memory as real-world networks are highly sparse and have limited connections for each node v i .
Given D and maxk, the primal formulation of the weighted kernel PCA [22] is given by: where e l ð Þ~e l ð Þ 1 , . . . ,e l ð Þ N tr h i > are the projections onto the eigenspace, l~1, . . . ,maxk-1 indicates the number of score variables required to encode the maxk clusters. However, it was shown in [27] that we can discover more than maxk communities using these We note that N tr %N i.e. the number of nodes in the training set is much less than the total number of nodes in the large scale network. The kernel matrix V is constructed by calculating the similarity between the adjacency list of each pair of nodes in the training set.
is calculated by estimating the cosine similarity between the adjacency lists x i and x j using notions of set intersection and union. This corresponds to using a normalized linear kernel function K x,z ð Þ~x > z x k k z k k [23]. The primal clustering model is then represented by: where w : R N ?R d h is the feature map i.e. a mapping to highdimensional feature space d h and b l are the bias terms, l~1, . . . ,maxk-1. For large scale networks we can utilize the explicit expression of the underlying feature map as shown in [25] and set d h~N . The dual problem corresponding to this primal formulation is given by: where M D is the centering matrix which is defined as The a (l) are the dual variables and the kernel function K : R N |R N ?R plays the role of similarity function. The dual predictive model is: which provides clustering inference for the adjacency list x corresponding to the validation/test node v.

Multilevel Hierarchical KSC
We use the predictive KSC model in the dual to get the latent variable matrix for the validation set V valid represented as P valid~e1 , . . . ,e N valid ½ > and the test set V test (entire network) denoted by P test . In [27] the authors create an affinity matrix S valid using the latent variable matrix P valid which is a N valid |(maxk-1) matrix, as: where CosDist( : , : ) function calculates the cosine distance between 2 vectors and takes values between [0,2]. Nodes which belong to the same community will have CosDist(e i ,e j ) closer to 0, i, j in the same cluster. It was shown in [27] that a rotation of the S valid matrix has a block diagonal structure. This block diagonal structure was used to identify the ideal number of clusters k in the network using the concept of entropy and balanced clusters.

Determining the Distance Thresholds
We propose an iterative bottom-up approach on the validation set to determine the set of distance thresholds T . In our approach, we refer to the affinity matrix at the ground level of hierarchy as valid . The S (0) valid matrix is obtained by calculating the CosDist( : , : ) between each element of the latent variable matrix P valid as mentioned earlier. After several empirical evaluations, we observe that distance threshold at level 0 of hierarchy can be set to values between [0.1,0.2]. In our experiments we set t (0)~0 :15. This allows to make the approach tractable to large scale networks which will be explained later. We then use a greedy approach to select the validation node with maximum number of similar nodes in the latent space i.e we select the projection e i which has a maximum number of projections e j satisfying S (0) valid (i,j)vt (0) . We put the indices of these nodes in C (0) 1 representing the 1 st cluster at level 0 of hierarchy. We then remove these nodes and corresponding entries from S (0) valid to obtain a reduced matrix. This process is repeated iteratively until S (0) valid becomes empty. Thus, we obtain the set C (0)~f C (0) 1 , . . . ,C (0) q g where q is the total number of clusters at ground level of hierarchy. The set C (0) has communities along with the indices of the nodes in these communities.
To obtain the clusters at the next level of hierarchy we treat the communities at the previous levels as nodes. We then calculate the average cosine distance between these nodes using the information present in them. At each level h of hierarchy we create a new affinity matrix as: where D : D represents the cardinality of the set. In order to determine the threshold at level h of hierarchy, we estimate the minimum   The best results w.r.t. various quality metrics when compared with the ground truth communities for each benchmark network is highlighted. doi:10.1371/journal.pone.0099966.t002 cosine distance between each individual cluster and the other clusters (not considering itself). Then, we select the mean of these values as the new threshold for that level to combine clusters. This makes the approach different from the classical single-link clustering where we combine two clusters which are closest to each other at a given level of hierarchy and the average-link agglomerative clustering where we combine based on the average distance between all the clusters. The reason for using mean of these minimum cosine distance values as the new threshold is that if we consider the minimum of all the distance values then there is a risk of only combining 2 clusters at that level. However, it is desirable to combine multiple sets of different clusters. Thus, the new threshold t (h) at level h is set as: We use this process iteratively till we reach the coarsest cluster where we have 1 cluster containing all the nodes. As a consequence we obtain the hierarchical clustering fC (0) , . . . ,C (maxh) g automatically. As we move from one level of hierarchy to another the value of distance threshold increases since we are merging large clusters at coarser levels of hierarchy. We finally end up with a set of increasing distance thresholds ft (0) , . . . ,t (maxh) g.

Requirements for Feasibility to Large Scale Networks
The whole large scale network is used as test set. The latent variable matrix for the test set is obtained by out-of-sample extensions of the predictive KSC model and defined as P test~e1 , . . . ,e Ntest ½ > . Since we use the entire network as test set, therefore, N test~N . The P test matrix is a N|(maxk-1) dimensional matrix. So, we can store this P test matrix in memory but cannot create an affinity matrix of size N|N due to memory constraints.
To make the approach feasible to large scale network we put a condition that the maximum size of a cluster at ground level cannot exceed 10,000 (depending on the available computer memory) and the maximum number of clusters allowed at the ground level is 10,000. This limits the size of the affinity matrix at that level of hierarchy to be less than 10,000610,000. It also effects the choice of the initial value of the distance threshold t (0) . If we set t (0) too high (&0:2) then majority of the nodes at the ground level in the test case will fall in one community resulting in one giant connected component. If we set the value of t (0) too low (%0:1) then we will end up with lot of singleton clusters at the ground level in the test case. In our experiments, we observed that the interval any value between [0.1,0.2] is good choice for the initial threshold value at level 0 of hierarchy. To be consistent we chose t (0)~0 :15 for all the networks.

Multilevel Hierarchical KSC for Test Nodes
The validation set is a representative subset of the whole network as shown in [26]. Thus, the threshold set can be used to obtain a hierarchical clustering for the entire network. To make the proposed approach self-tuned, we use t (i) wt (0) w0:15, i.0, during the test phase.
In order to prevent creating the affinity matrix for the large network we follow a greedy procedure. We select the projection of the first test node and calculate its similarity with the projections of all the test nodes. We then locate the indices (j) of those projections s.t. CosDist(e 1 ,e j )vt (1) . If the total number of such indices is less than 10,000 then we put them in cluster C (1) 1 otherwise we select the first 10,000 indices and place them in cluster C (1) 1 . This is due to the constraint that the size of a cluster (C (1) 1 ) at ground level cannot exceed 10,000. We then remove entries corresponding to those projections in P test to obtain a reduced matrix. We perform this procedure iteratively until P test is empty to obtain C (1)~f C (1) 1 , . . . ,C (1) r g where r is the total number of clusters at hierarchical level 1. After the 1 st level, we use the same procedure that was for validation set i.e. creating an affinity matrix at each level using the cluster information along with the threshold set to obtain the hierarchical structure in an agglomerative fashion. The cluster memberships are propagated iteratively from the 1 st level to the highest level of hierarchy. The multilevel hierarchical kernel spectral clustering (MH-KSC) method is described in Figure 3 which refers to Algorithm 2 and Algorithm 3 in Figure 4 and Figure 5 respectively.

Time Complexity Analysis
The two steps in our proposed approach which require the maximum computation time are the out-of-sample extensions for the test set and the creation of the affinity matrix from the ground level clusters.
Since we use the entire network as test set the time required for out-of-sample extension is O (N tr |N). Our greedy procedure to obtain the clustering information at the ground level C (1) requires O(r|N) computations where r is the number of clusters at 1 st level of hierarchy for the test set. This is because for each cluster C (1) 1 [C (1) we remove all the indices belonging in that cluster from the matrix P test . As a result the size of P test decreases till it reduces to zero resulting in O(r|N) computations. The affinity matrix  Table 5. The best results are highlighted and '-' is used in of absence of available partitions. doi:10.1371/journal.pone.0099966.t005 Table 6. Results of Infomap and OSLOM methods.  However, as shown in [25], we can perform the out-of-sample extensions in parallel on n computers and rows of the affinity matrix can also be calculated in parallel thereby reducing the complexity by 1 n .

Experimental Results
We conducted experiments on 2 synthetic datasets obtained from the toolkit in [4] and 7 real-world networks obtained from Stanford SNAP library (http://snap.stanford.edu/data/index. html).

Synthetic Network Experiments
The synthetic networks are referred as Net 1 and Net 2 and have 2,000 and 50,000 nodes respectively. The ground truth for these 2 benchmark networks are known at 2 levels of hierarchy. These 2 levels of hierarchy for these benchmark networks are obtained by using 2 different mixing parameters i.e. m 1 and m 2 for macro and micro communities. We fixed m 1~0 :1 and m 2~0 :2 in our experiments. Since the ground truth is known beforehand, we evaluate the communities obtained by our proposed MH-KSC approach using an external quality metric like Adjusted Rand Index (ARI) and Variation of Information (VI) [33]. We also evaluate the cluster information using internal cluster quality metrics like Modualrity (Q) [3] and Cut-Conductance (CC) [29]. We compare MH-KSC with Louvain, Infomap and OSLOM. Figures 6 and 7 showcase the result of MH-KSC algorithm on the Net 1 and Net 2 respectively. From Figures 6a and 7a, we observe the affinity matrices generated corresponding to the test set for Net 1 and Net 2 respectively. From Figures 6b and 7b, we can observe the communities prevalent in the original network and the communities estimated by MH-KSC method for Net 1 and Net 2 respectively. In Net 1 there are 9 macro communities and 37  Table 1 illustrates the first 10 levels of hierarchy for Net 1 and Net 2 and evaluates the clusters obtained at each level of hierarchy w.r.t. quality metrics ARI, VI, Q and CC. Higher values of ARI (close to 1) and lower values of VI (close to 0) represent good quality clusters. Both these external quality metrics are normalized as shown in [33]. Higher values of modularity (Q close to 1) and lower values of cut-conductance (CC close to 0) indicate better clustering information. Table 2 provides the result of Louvain, Infomap and OSLOM methods and compares it with the best levels of hierarchy for Net 1 and Net 2 . The Louvain, Infomap and OSLOM methods require multiple runs as in each iteration they result in a different partition. We perform 10 runs and report the mean results in Table 2. From Table 2, it can be observed that the best results for Louvain and Infomap methods generally occur at finer levels of hierarchy w.r.t. to ARI, VI and Q metric. Thus, these two methods work well to identify macro communities. The Louvain method works the better than MH-KSC for Net 2 at macro and micro level. However, it cannot obtain similar quality micro communities when compared with MH-KSC method for Net 1 as inferred from Table 2. The Infomap method performs the worst among all the methods w.r.t. detection of communities at coarser levels of granularity. OSLOM performs well w.r.t. to locating both macro communities for Net 1 and micro communities for Net 2 as observed from Table 2. It performs better than any method w.r.t. locating micro communities for Net 2 w.r.t. ARI and VI metric. However, it performs worst while trying to identify the macro communities for the same benchmark network. The MH-KSC performs best on Net 1 while it performs better w.r.t. locating macro communities for Net 2 .

Real-Life Network Experiments
We experimented on 7 real-life networks from the Stanford SNAP datasets. These networks are anonymous networks and are converted to undirected and unweighted networks before performing experiments on them. Table 3 provides information about topological characteristics of these real-life networks. The Fb and Epn networks are social networks, PGP is a trust based network, Cond is a collaboration network between researchers, Enr is an email network, Imdb is an actor-actor collaboration network and Utube is a web graph depicting friendship between the users of Youtube.
In case of real-life networks the true hierarchical structure is not known beforehand. Hence, it is important to show whether they exhibit hierarchical organization which can be tested by identifying good quality clusters w.r.t. internal quality metrics like Q and CC at multiple levels of hierarchy.
We showcase the results for 10 levels of hierarchy in a bottomup fashion for the MH-KSC method in Table 4. The finest level of hierarchy has all nodes in one community and is not very insightful. Clusters at finer levels of granularity comprises giant connected components. So, it is more meaningful to give more emphasis to fine grained clusters at coarser levels of hierarchy. To show that real-life networks exhibit hierarchy we evaluate our proposed MH-KSC approach in Table 4.
We compare MH-KSC algorithm with Louvain [15], Infomap [7] and OSLOM [21]. We perform 10 runs for each of these methods as they generate a separate partition each time when they are executed. The mean results of Louvain method is reported in Table 5. Table 6 showcases the results for Infomap and OSLOM method.
From Table 5 it is evident that the Louvain method works best w.r.t. the modularity (Q) criterion. This aligns with methodology as it is trying to optimize for Q. However, the Louvain method always performs worse than MH-KSC algorithm w.r.t. cut-conductance CC as observed from Tables 4 and 5. Another issue with the Louvain method is that except for the Fb and PGP networks it is not able to detect (,1000 clusters) high quality clusters at finer levels of granularity. This is attributed to the resolution limit problem suffered by Louvain method. From Table 6 we observe that the Infomap method produces only 2 levels of hierarchy. In most of the cases, the clusters at one level of hierarchy perform good w.r.t. only 1 quality metric except the PGP and Cond networks. The difference between the quality of the clusters at the network along with 2 levels of hierarchy. In Figure 9 we plot the results for PGP net corresponding to MH-KSC algorithm using 2 fine, 4 intermediate and 2 coarse levels of the hierarchical organization. For Louvain method we use 3 rd and 4 th level of hierarchy as inputs for the fine clusters, 4 th and 5 th level of hierarchy as inputs for intermediate clusters and 5 th and 6 th level of hierarchy as inputs for plotting coarsest clusters. The Infomap method only generates 2 level of hierarchy which correspond to a plot for coarse clusters. Similarly, for OSLOM we plot coarse and fine clusters. The results for Louvain, Infomap and OSLOM methods are depicted in Figure 10. Figures 9 and 10 show that MH-KSC algorithm allows to depict richer structures than the other methods. It has more flexibility and allows the visualization at coarser, intermediate and finer levels of granularity. From Figures 10a, 10b, 10c and Table 5, we observe that the Louvain method can only detect quality clusters at coarser levels of granularity and cannot detect less than 1,00 communities. While the Infomap method can only locate giant connected components for the PGP network as observed from Figure 10d and Table 6. The OSLOM method also seems to work reasonably well as observed from Figures 10e and 10f. However, it detects fewer levels of hierarchy and thus has less flexibility in terms of selection for the level of hierarchy than the proposed MH-KSC approach.
We provide a visualization of the 2 best layers of hierarchy for Epn network based on the Q and the CC criterion for MH-KSC, Louvain, Infomap and OSLOM methods respectively in Figures 11 and 12. The result for Infomap method in both the figures is the same as it only generates 2 levels of hierarchy.

Conclusions
We proposed a new multilevel hierarchical kernel spectral clustering (MH-KSC) algorithm. The approach relies on the KSC primal-dual formulation and exploits the structure of the projections in the eigenspace. The projections of the validation set provided a set (T) of increasing distance thresholds. These distance thresholds were used along with affinity matrix obtained from the projections in an iterative procedure to obtain a multilevel hierarchical organization in a bottom-up fashion. We highlighted some of the necessary conditions for the feasibility of the approach to large scale networks. We showed that many reallife networks exhibit hierarchical structure. Our proposed approach was able to identify good quality clusters for both coarse as well as fine levels of granularity. We compared and evaluated our MH-KSC approach against several state-of-the-art large scale hierarchical community detection techniques.