Python中基于igraph的社区检测

Python中基于igraph的社区检测,python,social-networking,igraph,Python,Social Networking,Igraph,我需要在网络中检测社区。 但是,我不能获得会员资格 # Script from igraph import * karate = Graph.Read_Pajek("karate.gml") karate.simplify() cl = karate.community_fastgreedy() print cl.membership # ---> Not work 有人知道如何获取成员吗?此方法返回完整的树状图,因此您需要首先将其转换为群集 from igraph import *

我需要在网络中检测社区。 但是,我不能获得会员资格

# Script
from igraph import *

karate = Graph.Read_Pajek("karate.gml")
karate.simplify()
cl = karate.community_fastgreedy()
print cl.membership # ---> Not work

有人知道如何获取成员吗?

此方法返回完整的树状图,因此您需要首先将其转换为群集

from igraph import *
karate = Nexus.get("karate")
cl = karate.community_fastgreedy()
cl.as_clustering().membership

# [0, 1, 1, 1, 0, 0, 0, 1, 2, 1, 0, 0, 1, 1, 2, 2, 0, 1, 2, 0, 
#  2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]

该方法返回一个完整的树状图,因此需要首先将其转换为聚类

from igraph import *
karate = Nexus.get("karate")
cl = karate.community_fastgreedy()
cl.as_clustering().membership

# [0, 1, 1, 1, 0, 0, 0, 1, 2, 1, 0, 0, 1, 1, 2, 2, 0, 1, 2, 0, 
#  2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]