k_clique_communities#
- k_clique_communities(G, k, cliques=None)[源代码]#
使用渗流方法在图中寻找 k-团社区。
k-团社区是指通过相邻(共享 k-1 个节点)的 k-团可达的所有大小为 k 的团的并集。
- 参数:
- GNetworkX 图
- k整型
最小团的大小
- cliques: 列表或生成器
预先计算的团(使用 networkx.find_cliques(G))
- 返回:
- 为每个 k-团社区生成一个节点集合。
参考资料
[1]Gergely Palla, Imre Derényi, Illés Farkas1, and Tamás Vicsek, Uncovering the overlapping community structure of complex networks in nature and society Nature 435, 814-818, 2005, doi:10.1038/nature03607
示例
>>> G = nx.complete_graph(5) >>> K5 = nx.convert_node_labels_to_integers(G, first_label=2) >>> G.add_edges_from(K5.edges()) >>> c = list(nx.community.k_clique_communities(G, 4)) >>> sorted(list(c[0])) [0, 1, 2, 3, 4, 5, 6] >>> list(nx.community.k_clique_communities(G, 6)) []