def test_DER(self):
     g = get_string_graph()
     coms = algorithms.der(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)
Пример #2
0
        fields = line.strip("\n").split("\t")
        if (options.bipartite):
            g.add_node(fields[0], bipartite=0)
            g.add_node(fields[1], bipartite=1)
        g.add_edge(fields[0], fields[1], weight=float(fields[2]))

    print(g.number_of_nodes())
    print(g.number_of_edges())
    if (options.method == 'leiden'):
        communities = algorithms.leiden(g, weights='weight', **clust_kwargs)
    elif (options.method == 'louvain'):
        communities = algorithms.louvain(g, weight='weight', **clust_kwargs)
    elif (options.method == 'cpm'):
        communities = algorithms.cpm(g, weights='weight', **clust_kwargs)
    elif (options.method == 'der'):
        communities = algorithms.der(g, **clust_kwargs)
    elif (options.method == 'edmot'):
        communities = algorithms.edmot(g, **clust_kwargs)
    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'):