Exemplo n.º 1
0
    def test_wCommunities(self):

        g = get_string_graph()
        nx.set_edge_attributes(g, values=1, name='weight')

        communities = algorithms.wCommunity(g,
                                            min_bel_degree=0.6,
                                            threshold_bel_degree=0.6)
        self.assertEqual(type(communities.communities), list)
        if len(communities.communities) > 0:
            self.assertEqual(type(communities.communities[0]), list)
            if len(communities.communities[0]) > 0:
                self.assertEqual(type(communities.communities[0][0]), int)

        g = nx.karate_club_graph()
        nx.set_edge_attributes(g, values=1, name='weight')

        communities = algorithms.wCommunity(g,
                                            min_bel_degree=0.6,
                                            threshold_bel_degree=0.6)
        self.assertEqual(type(communities.communities), list)
        if len(communities.communities) > 0:
            self.assertEqual(type(communities.communities[0]), list)
            if len(communities.communities[0]) > 0:
                self.assertEqual(type(communities.communities[0][0]), int)
Exemplo n.º 2
0
 elif (options.method == 'danmf'):
     communities = algorithms.danmf(g, **clust_kwargs)
 elif (options.method == 'ego_networks'):
     communities = algorithms.ego_networks(g, **clust_kwargs)
 elif (options.method == 'egonet_splitter'):
     communities = algorithms.egonet_splitter(g, **clust_kwargs)
 elif (options.method == 'nmnf'):
     communities = algorithms.nmnf(g, **clust_kwargs)
 elif (options.method == 'nnsed'):
     communities = algorithms.nnsed(g, **clust_kwargs)
 elif (options.method == 'slpa'):
     communities = algorithms.slpa(g, **clust_kwargs)
 elif (options.method == 'bimlpa'):
     communities = actlgorithms.bimlpa(g, **clust_kwargs)
 elif (options.method == 'wcommunity'):
     communities = algorithms.wCommunity(g, **clust_kwargs)
 elif (options.method == 'aslpaw'):
     import warnings
     with warnings.catch_warnings():
         warnings.filterwarnings("ignore")
         communities = algorithms.aslpaw(g)
 elif (options.method == 'external'):
     from collections import defaultdict
     from cdlib import NodeClustering
     coms_to_node = defaultdict(list)
     f = open(options.external, 'r')
     for line in f:
         fields = line.strip("\n").split("\t")
         coms_to_node[fields[0]].append(fields[1])
     coms = [list(c) for c in coms_to_node.values()]
     communities = NodeClustering(coms,