gpt4 book ai didi

python-3.x - 属性错误 : module 'networkx.algorithms.community' has no attribute 'best_partition'

转载 作者:行者123 更新时间:2023-12-03 21:01:56 25 4
gpt4 key购买 nike

好吧,我正在尝试使用 社区检测算法网络x 在著名的 facebook snap 数据集上。
这是我的代码:

import networkx as nx
import matplotlib.pyplot as plt
from networkx.algorithms import community
from networkx.algorithms.community.centrality import girvan_newman

G_fb = nx.read_edgelist("./facebook_combined.txt",create_using = nx.Graph(), nodetype=int)

parts = community.best_partition(G_fb)
values = [parts.get(node) for node in G_fb.nodes()]

但是当我运行单元格时,我面临的标题错误是:
AttributeError: module 'networkx.algorithms.community' has no attribute 'best_partition'

有什么建议吗?

最佳答案

我在 CS224W 中遇到过这个AttributeError: module 'community' has no attribute 'best_partition' enter image description here
请更改此文件 karate.py
将导入替换为import community.community_louvain as community_louvain然后它对我有用。

关于python-3.x - 属性错误 : module 'networkx.algorithms.community' has no attribute 'best_partition' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53017174/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com