Algorithm 为什么igraph spinglass给我';无法使用未连接的图形';?

Algorithm 为什么igraph spinglass给我';无法使用未连接的图形';?,algorithm,python-2.7,nodes,igraph,vertices,Algorithm,Python 2.7,Nodes,Igraph,Vertices,我正在试验不同的社区检测算法,并且能够得到除spinglass之外的所有社区检测算法的一些结果。我使用的是完全相同的图形,但我得到了一个错误 代码 错误 我确实有边和顶点,同一个图与igraph中的所有其他社区检测算法(领先特征向量、GN、InfoMap、标签传播、多级、Walktrap)一起工作,而不是spinglass igraph中包含的Spingglass聚类算法的实现仅适用于连通图。您必须将图形分解为其连接的组件,在每个连接的组件上运行群集,然后手动合并群集的成员向量。如前所述 spi

我正在试验不同的社区检测算法,并且能够得到除spinglass之外的所有社区检测算法的一些结果。我使用的是完全相同的图形,但我得到了一个错误

代码

错误


我确实有边和顶点,同一个图与igraph中的所有其他社区检测算法(领先特征向量、GN、InfoMap、标签传播、多级、Walktrap)一起工作,而不是spinglass

igraph中包含的Spingglass聚类算法的实现仅适用于连通图。您必须将图形分解为其连接的组件,在每个连接的组件上运行群集,然后手动合并群集的成员向量。

如前所述


spinglass聚类算法的实现 包含在igraph中仅适用于连通图。你必须 将图形分解为其连接的组件,运行群集 在每个连接的组件上,然后合并成员资格 手动创建群集的向量

您可以使用iGraph的
集群
方法分解主图,如下面的示例所示:

    clusters    = g.clusters()
    giant       = clusters.giant() ## using the biggest component as an example, you can use the others here.
    communities = giant.community_spinglass()
File "/Library/Python/2.7/site-packages/igraph/__init__.py", line 1265, in community_spinglass
membership = GraphBase.community_spinglass(self, *args, **kwds)
igraph._igraph.InternalError: Error at clustertool.cpp:286: Cannot work with unconnected graph, Invalid value
    clusters    = g.clusters()
    giant       = clusters.giant() ## using the biggest component as an example, you can use the others here.
    communities = giant.community_spinglass()