@@ -20,7 +20,7 @@ def main():
2020 #----------------------------------------------------------------------
2121 # Stochastic block model parameters
2222 #----------------------------------------------------------------------
23- n_vertices = 3000 # number of vertices
23+ n_vertices = 200 # number of vertices
2424 n_communities = 2 # number of communities
2525
2626 # Fixing cin > cout is referred to as the assortative case, because vertices
@@ -29,7 +29,7 @@ def main():
2929 # is that any tractable algorithm will only detect communities if
3030 # abs(cin - cout) > n_communities*sqrt(c), where c is the average degree.
3131 cin = 15
32- cout = 5
32+ cout = 1
3333 probability_matrix = (1.0 / n_vertices )* (np .full ((n_communities ,n_communities ), cout , dtype = int ) + np .diag ([cin - cout ]* n_communities )) # matrix of edge probabilities
3434 sbm = SBM (n_vertices , n_communities , probability_matrix )
3535 print ("Average degree: {}, abs(cin - cout): {}, n_commuties*sqrt(c): {}" .format (sbm .average_degree , abs (cin - cout ), n_communities * np .sqrt (sbm .average_degree )))
@@ -57,13 +57,13 @@ def main():
5757 n_clusters = 2
5858 if n_clusters != n_communities :
5959 print ("Number of clusters ({}) is not equal to number of communities generated by the SBM ({})!" .format (n_clusters , n_communities ))
60- spectral_labels , eigvals , eigvects , W = SpectralClustering (n_clusters , BetheHessian (sbm .adjacency_matrix )) # spectral clustering
60+ spectral_labels , eigvals , eigvects , W = SpectralClustering (n_clusters , ModularityMatrix (sbm .adjacency_matrix ), "ModularityMatrix" ) # spectral clustering
6161 well_placed_vertices = pg .permutation_calculator (sbm .community_labels , spectral_labels , n_clusters )
6262 print ("Spectral clustering accuracy: " + str (100 * well_placed_vertices / n_vertices ) + "%" )
6363
6464 # Eigenvalues and eigenvectors
6565 if n_vertices <= PLOT_MAX_NODES :
66- plt .title ("Histogram of Bethe Hessian matrix eigenvalues" )
66+ plt .title ("Histogram of matrix eigenvalues" )
6767 plt .hist (eigvals , bins = 100 ) # plot histogram of the eigenvalues
6868 if n_clusters <= 2 :
6969 plt .figure ()
0 commit comments