gpt4 book ai didi

python - 模块 'networkx' 没有属性 'blockmodel'?

转载 作者:太空宇宙 更新时间:2023-11-03 14:49:36 26 4
gpt4 key购买 nike

我正在尝试使用 networkx blockmodel 函数,但 Python 一直说没有属性“blockmodel”。我在链接 here 中使用文档中的示例代码.

我确实安装了 networkx,并且许多其他功能都在工作。只有这个似乎在提示。非常感谢您的帮助。

最佳答案

blockmodel 函数已在最新版本的 networkx(您正在查看较旧的文档)中替换为 quotient_graph
下面是一个生成 block 模型的例子

>>> G = nx.path_graph(6)
>>> partition = [{0, 1}, {2, 3}, {4, 5}]
>>> M = nx.quotient_graph(G, partition, relabel=True)
>>> list(M.edges())
[(0, 1), (1, 2)]

参见 https://networkx.github.io/documentation/stable/reference/algorithms/generated/networkx.algorithms.minors.quotient_graph.html?highlight=blockmodel获取更新的文档。

关于python - 模块 'networkx' 没有属性 'blockmodel'?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46759906/

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