使用igraph在python中绘制图形

2024-09-29 23:20:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我的代码格式如下所示。如何在图形中输出communities对象?我尝试使用plot(communities),但我不支持plot。在

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], 
.....]

Tags: 对象代码fromimport图形plotas格式
1条回答
网友
1楼 · 发布于 2024-09-29 23:20:50

这很简单。使用这个:

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)

现在有个诀窍:

^{pr2}$

对您想要的社区重复此操作。

另请参见:https://stackoverflow.com/a/44881027/5025009

相关问题 更多 >

    热门问题