我将在这里使用这张图作为示例。
import pandas as pd
import graph_tool.all as gt
g = gt.collection.data["polbooks"]
state = gt.minimize_blockmodel_dl(g)
state.draw(pos=g.vp["pos"], vertex_shape=state.get_blocks())
正如你所看到的,只形成了 3 个块,但是当我使用这些命令时:
state.get_B() #number of blocks
返回105
state.get_N() #Returns the total number of nodes.
返回105
state.get_nonempty_B()
返回3
我的问题是,因为我确切地知道形成了多少个社区,为什么当使用上面的命令时,当我们清楚地看到只有 3 个时,我形成的社区数量是 105 个,以及如何准确获取哪些节点是每个社区?
根据https://graph-tool.skewed.de/static/doc/demos/inference/inference.html, “出于算法效率的原因,返回的组标签不一定是连续的,它们可能位于范围 [0,N-1] 的任何子集中,其中 N 是网络中的节点数。