首页 > 解决方案 > 使用networkx在无向图中进行社区搜索?

问题描述

我想使用 networkx 在网络中发现社区。我正在研究的网络是猫脑,可以下载为 .EDGES 文件。它是一个无向图。我是这样读的:

import networkx as nx
import matplotlib.pyplot as plt

cat_brain = ".//data//cat_brain.graphml"
cat = nx.read_graphml(cat_brain)

plt.title("Cat brain")
nx.draw(cat,pos=nx.spring_layout(cat),node_size=25, width=0.1) # use spring layout

我想用 networkx 来更详细地描述这个社区。甚至可能评估其弹性和连通性。但是,我很难找到有关此过程的大量信息。到目前为止我所做的是:

from networkx.algorithms.approximation import clique
from networkx.algorithms.community import k_clique_communities

print("Cat brain basic graph info:",nx.info(cat))
print("max clique of cat",clique.max_clique(cat))

我想运行相似性分析并搜索网络中的社区。此后,我将运行一个分裂算法来隔离社区,并最终能够绘制网络,重新设计颜色以显示多个社区。但是,networkx 社区算法的文档仅限于一种算法。networkx 中是否有工具可以完成这项工作?我应该在别处寻找另一个 python 包吗?

非常感谢!

标签: pythonnetworkinggraphnetworkxinfrastructure

解决方案


推荐阅读