python - 最大错误(nx.connected_component_subgraphs(),)没有属性 'connected_component_subgraphs'

标签 python networkx tweepy

我正在尝试运行这段代码:

graph = nx.Graph()

largest_subgraph = max(nx.connected_component_subgraphs(graph), key=len)

但我收到此错误消息:

AttributeError: module 'networkx' has no attribute 'connected_component_subgraphs'

我该如何解决这个问题?

最佳答案

connected_component_subgraphs() 已从 2.4 版中删除。

相反,使用这个:

graph = nx.Graph()

connected_component_subgraphs = (graph.subgraph(c) for c in nx.connected_components(graph))

largest_subgraph = max(connected_component_subgraphs, key=len)

根据 this answer .

关于python - 最大错误(nx.connected_component_subgraphs(),)没有属性 'connected_component_subgraphs',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64198940/

相关文章:

python - 小方 block 而不是传说中的线条?

python - 写入文件时出现 UnicodeDecodeError

python - 使用 Tweepy 从 Twitter 获取特定位置的推文

api - 搜索特定 URL 的推文 Twitter API 1.1

python - 在 Pandas 数据框中的两个单独的列中显示相同的行号

python - Tensorflow Contrib Metrics 始终返回 0.0

python - 如何在回溯中撤消?我在使用递归回溯方法时遇到问题

python - "IncompleteRead"使用 Python 检索 Twitter 数据时出错

python - 设置手形光标以选取 matplotlib 文本

linear-algebra - networkx 无法计算代数连通性