我的代码格式如下所示。如何在图表中输出社区对象?我尝试使用情节(社区),但我得到的不支持绘图。
import igraph as ig
from edgeboost.EdgeBoost import CommunityEdgeBoost
G = ig.Graph.Erdos_Renyi(200,0.1)
#creates EdgeBoost object
... edgeBooster = CommunityEdgeBoost(lambda
x:x.community_multilevel(),"common_neighbors",numIterations = 10)
#detect communities
... communities = edgeBooster.detect_communities(G)
print communities
[[0, 34, 55, 57, 94, 136, 191, 105, 116, 124, 170], [1, 24, 36, 98,
100, 142, 150, 173, 38, 43, 44, 51, 66, 69, 84, 97, 141, 155, 185],
[2, 74, 83, 6, 31, 48, 109, 113, 121, 127, 160, 163, 174, 175],
.....]
答案 0 :(得分:0)
非常简单。使用这个:
import igraph as ig
from edgeboost.EdgeBoost import CommunityEdgeBoost
G = ig.Graph.Erdos_Renyi(200,0.1)
#creates EdgeBoost object
edgeBooster = CommunityEdgeBoost(lambda x:x.community_multilevel(),"common_neighbors",numIterations = 10)
#detect communities
communities = edgeBooster.detect_communities(G)
# Define the community/subgraph/subnetwork
community_0 = G.subgraph(communities[0])
#plot it
ig.plot(community_0)
重复所需的社区。 strong>