我有一段使用igraph
库的Python代码。
import igraph
edge = [(0, 6), (0, 8), (0, 115), (0, 124), (0, 289), (0, 359), (0, 363), (6, 60), (6, 115), (6, 128), (6, 129), (6, 130), (6, 131), (6, 359), (6, 529), (8, 9), (8, 17), (8, 115)]
G = igraph.Graph(edges=edge, directed=False)
G.vs['label'] = nodes
G.es["weight"] = weights
dendrogram = G.community_edge_betweenness()
clusters = dendrogram.as_clustering()
membership = clusters.membership
out = pd.Series(membership, index=nodes)
我需要将它转换为networkx
库。
import networkx as nx
G = nx.Graph(edges)
dendrogram = nx.edge_betweenness_centrality(G)
clusters = nx.clustering(dendrogram)
membership = clusters.membership
out = pd.Series(membership, index=nodes)
然而,在networkx
库中无法对dendrogram
进行聚类。有人可以帮忙将igraph
代码复制到networkx
聚类中吗?
igraph
,能请您解释一下as_clustering()
是干嘛的吗?从文档上看,它似乎和nx.clustering
命令(返回每个节点的聚类系数)完全不同。 - Joel