Graph 创建具有重叠顶点的子图

Graph 创建具有重叠顶点的子图,graph,networkx,partitioning,metis,Graph,Networkx,Partitioning,Metis,我一直在寻找可以创建顶点重叠的子图的包。 根据我在Networkx和metis中的理解,可以将图形划分为两个或多个部分。但我找不到如何划分成具有重叠节点的子图 import networkx as nx from cdlib import algorithms if __name__ == '__main__': g = nx.karate_club_graph() coms = algorithms.angel(g, threshold=4, min_commun

我一直在寻找可以创建顶点重叠的子图的包。 根据我在
Networkx
metis
中的理解,可以将图形划分为两个或多个部分。但我找不到如何划分成具有重叠节点的子图

import networkx as nx
from cdlib import algorithms
   
if __name__ == '__main__':
 
    g = nx.karate_club_graph()

    coms = algorithms.angel(g, threshold=4, min_community_size=10)
    print(coms.method_name)
    print(coms.method_parameters)  # Clustering parameters)
    print(coms.communities)
    print(coms.overlap)
    print(coms.node_coverage)
关于支持重叠顶点分区的库的建议将非常有用

编辑:我在CDLIB中尝试了
angle
算法,将原始图划分为具有4个重叠节点的子图

import networkx as nx
from cdlib import algorithms
   
if __name__ == '__main__':
 
    g = nx.karate_club_graph()

    coms = algorithms.angel(g, threshold=4, min_community_size=10)
    print(coms.method_name)
    print(coms.method_parameters)  # Clustering parameters)
    print(coms.communities)
    print(coms.overlap)
    print(coms.node_coverage)
输出:

ANGEL
{'threshold': 4, 'min_community_size': 10}
[[14, 15, 18, 20, 22, 23, 27, 29, 30, 31, 32, 8], [1, 12, 13, 17, 19, 2, 21, 3, 7, 8], [14, 15, 18, 2, 20, 22, 30, 31, 33, 8]]
True
0.6470588235294118
从返回的社区中,我了解到1和3有4个节点的重叠,但2和3或1和3没有4个节点的重叠大小。 我不清楚如何指定重叠阈值(4个重叠) 这里是
算法。天使(g,阈值=4,最小社区大小=10)
。我尝试在这里设置threshold=4,以定义4个节点的重叠大小。但是,

:param threshold:正在[0,1]中合并阈值

我不知道如何将4个重叠转换为必须在边界[0,1]之间设置的值。建议将非常有用。

您可以查看: 他们有大量适用于networkX的社区查找算法,包括一些

  • 在旁注上
    函数的返回类型称为
    节点集群
    ,一开始可能会有点混乱,这里是,通常您只是想知道
特别是关于: 根据,阈值不是重叠阈值,而是如下使用:

如果比率大于(或等于)给定阈值,则应用合并并更新节点标签

  • 基本上,该值决定是否将节点进一步合并到更大的社区中,并且不等于重叠节点的数量

    import networkx as nx
    from cdlib import algorithms
       
    if __name__ == '__main__':
     
        g = nx.karate_club_graph()
    
        coms = algorithms.angel(g, threshold=4, min_community_size=10)
        print(coms.method_name)
        print(coms.method_parameters)  # Clustering parameters)
        print(coms.communities)
        print(coms.overlap)
        print(coms.node_coverage)
    
  • 另外,不要将“标签”与“节点标签”弄错(如中所示)。所引用的“标签”实际上与所使用的相关

关于改变该阈值的影响

[…]提高阈值,我们可以获得更多的社区,因为质量较低的合并无法进行

[根据@J.M.Arnold的评论]
从中可以看出,当
threshold>=1
时,仅使用
min\u comsize
值:

self.threshold=阈值
如果self.threshold<1:
self.min_community_size=max([3,min_comsize,int(1./(1-self.threshold)))
其他:
self.min\u community\u size=min\u comsize

你能检查我的编辑吗?我最好的猜测是
4/len(G)
但我以前从未使用过该算法谢谢你,我尝试了4/len(G.nodes)),该算法只返回了1个社区
[[0,1,10,12,13,14,15,16,17,18,19,2,20,22,23,26,27,28,29,3,30,31,32,33,4,5,7,8]
节点覆盖率为0.88。请您建议我是否可以从CDLIB尝试其他算法来创建重叠大小为4的子图。谢谢,我不知怎么错过了编辑。“合并已应用,节点标签已更新。”因此,
社区
中返回的节点与原始图表中的节点标签不对应?请澄清一下?该值决定是否将节点进一步合并到更大的社区中,而不是重叠节点的数量您是否检查了
阈值>1