Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/wix/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python max(nx.connected_component_subgraphs(),)的错误没有属性';连通分量子图';_Python_Networkx_Tweepy - Fatal编程技术网

Python max(nx.connected_component_subgraphs(),)的错误没有属性';连通分量子图';

Python max(nx.connected_component_subgraphs(),)的错误没有属性';连通分量子图';,python,networkx,tweepy,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' 如何解决这个问题?已从2.4版中删除连接的组件子图() 相反,请使用以下命令: graph

我正在尝试运行以下代码:

graph = nx.Graph()

largest_subgraph = max(nx.connected_component_subgraphs(graph), key=len)
但我收到了以下错误消息:

AttributeError: module 'networkx' has no attribute '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)

根据。

啊,好的,我明白了。将其设置为变量。我还认为应该是
nx.connected\u组件(图)
谢谢!不客气!是的,你不必把连通的分量子图设为变量;我只是为了可读性。bug最喜欢的栖息地是复杂而紧张的代码。对于丢失的“nx”的错误,我深表歉意;我现在改正了。我没有测试它,因为我没有安装networkx库。没关系。我很高兴我即将获得一些见解和帮助。非常感谢。是的,虫子喜欢在复杂的代码中找到家。。。