我读了T0.pkl,它包含一个用networkx创建的有向图,因此我把它转换成了igraph图。 接下来,我将Louvain应用到图中,现在我得到了一个louvain.VertexPartition.ModularityVertexPartition模块化我不知道怎么用
G0_nx = nx.read_gpickle("../snapshots_original/T0.pkl")
G0_nx_edges = list(G0_nx.edges)
G0_nx_nodes = list(G0_nx.nodes)
G0_ig = igraph.Graph(directed=True)
G0_ig.add_vertices(G0_nx_nodes)
G0_ig.add_edges(G0_nx_edges)
partition = louvain.find_partition(G0_ig, lv.ModularityVertexPartition)
首先,您可以绘制它以可视化集群:
如果你试着用一个简单的
您将获得类似于:
例如:
之后,您可以访问集群中的节点,就像使用以所需集群id为索引的列表一样:
您还应该检查Louvain库docs,其中概述了时态社区检测等其他特性。你知道吗
相关问题 更多 >
编程相关推荐