通过python在gephi中的簇数之间的差异

时间:2019-03-10 08:23:27

标签: python gephi

我是python的新手,我对集群的数量有疑问... 当我在gephi中使用girvan newman算法时,它计算出的簇数为11,但是在python中却不同,簇数为2。 问题是什么?  这是我的代码:

import networkx as nx
from collections import OrderedDict
from networkx.algorithms import community
import csv
import itertools
import pandas as pd
Inner = open('C:/Users/User/Desktop/input.csv')
g = nx.Graph()
# generate graph from input
for row in Inner:
   node_1 = int(row.strip().split(',')[0])
   node_2 = int(row.strip().split(',')[1])
   g.add_edge(node_1, node_2)
# calculate girvan_newman
new = community.girvan_newman(g)
next_level_communities = next(new)
print(sorted(map(sorted, next_level_communities)))

0 个答案:

没有答案