如何在pythonigraph中使用已完成的群集列表[list]对象创建VertexClustering对象?

2024-09-28 05:24:08 发布

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

我正在使用pythonigraph进行社区检测。我实现了我自己的社区检测算法,该算法生成一个list[list]对象,如[[1,2,3]、[4,5,6]、[7,8,9]]。现在我想知道我的社区检测结果的模块性,我必须将list[list]对象转换为python igraph VertexClustering对象,以使用VertexClustering.modularity函数。我该怎么做


Tags: 对象函数算法社区list模块性igraphmodularity
1条回答
网友
1楼 · 发布于 2024-09-28 05:24:08

嗯,这比看起来容易

您只需创建一个VertexExclustering对象,将图形和簇标签作为参数提供:

partition = VertexClustering(g, kmeans.labels_)

plot(partition)

这意味着您必须首先通过添加节点和边来构建图形

VertexClustering类文档here

我有点晚了,不过也许有人会发现这个答案很有用

相关问题 更多 >

    热门问题