def test_aslpaw(self): g = nx.karate_club_graph() coms = algorithms.aslpaw(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]), int)
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, g, "external", method_parameters={}, overlap=True) else: