Exemple #1
0
 def test_rberpots(self):
     g = get_string_graph()
     coms = algorithms.rber_pots(g)
     self.assertEqual(type(coms.communities), list)
     if len(coms.communities) > 0:
         self.assertEqual(type(coms.communities[0]), list)
         self.assertEqual(type(coms.communities[0][0]), str)
Exemple #2
0
 elif (options.method == 'eigenvector'):
     communities = algorithms.eigenvector(g, **clust_kwargs)
 elif (options.method == 'gdmp2'):
     communities = algorithms.gdmp2(g, **clust_kwargs)
 elif (options.method == 'greedy_modularity'):
     communities = algorithms.greedy_modularity(g,
                                                weight='weight',
                                                **clust_kwargs)
 #elif(options.method == 'infomap'):
 #	communities = algorithms.infomap(g)
 elif (options.method == 'label_propagation'):
     communities = algorithms.label_propagation(g, **clust_kwargs)
 elif (options.method == 'markov_clustering'):
     communities = algorithms.markov_clustering(g, **clust_kwargs)
 elif (options.method == 'rber_pots'):
     communities = algorithms.rber_pots(g, weights='weight', **clust_kwargs)
 elif (options.method == 'rb_pots'):
     communities = algorithms.rb_pots(g, weights='weight', **clust_kwargs)
 elif (options.method == 'significance_communities'):
     communities = algorithms.significance_communities(g, **clust_kwargs)
 elif (options.method == 'spinglass'):
     communities = algorithms.spinglass(g, **clust_kwargs)
 elif (options.method == 'surprise_communities'):
     communities = algorithms.surprise_communities(g, **clust_kwargs)
 elif (options.method == 'walktrap'):
     communities = algorithms.walktrap(g, **clust_kwargs)
 #elif(options.method == 'sbm_dl'):
 #	communities = algorithms.sbm_dl(g)
 #elif(options.method == 'sbm_dl_nested'):
 #	communities = algorithms.sbm_dl_nested(g)
 elif (options.method == 'lais2'):
Exemple #3
0
# CONSIGLIO: passare alla cella successiva che carica i risultati da file

# In[30]:

accuracy_spinglass = 0
accuracy_eigenvector = 0
accuracy_leiden = 0
accuracy_cpm = 0
accuracy_rber_pots = 0

for i in range(10):
    result_spinglass_tmp = algorithms.spinglass(g1)
    result_eigenvector_tmp = algorithms.eigenvector(g1)
    result_leiden_tmp = algorithms.leiden(g1)
    result_cpm_tmp = algorithms.cpm(g1, resolution_parameter=.00018)
    result_rber_pots_tmp = algorithms.rber_pots(g1, resolution_parameter=.32)

    #definizione colonne che servono per calcolare l'accuracy
    nodes1['community_spinglass'] = -1
    for i in range(len(result_spinglass_tmp.communities)):
        for j in result_spinglass_tmp.communities[i]:
            nodes1.loc[j, 'community_spinglass'] = i
    nodes1['community_eigenvector'] = -1
    for i in range(len(result_eigenvector_tmp.communities)):
        for j in result_eigenvector_tmp.communities[i]:
            nodes1.loc[j, 'community_eigenvector'] = i
    nodes1['community_leiden'] = -1
    for i in range(len(result_leiden_tmp.communities)):
        for j in result_leiden_tmp.communities[i]:
            nodes1.loc[j, 'community_leiden'] = i
    nodes1['community_cpm'] = -1