Sat*_*and 11 python error-handling networkx
B = nx.Graph()
B.add_nodes_from(data['movie'].unique(), bipartite=0, label='movie')
B.add_nodes_from(data['actor'].unique(), bipartite=1, label='actor')
B.add_edges_from(edges, label='acted')
A = list(nx.connected_component_subgraphs(B))[0]
Run Code Online (Sandbox Code Playgroud)
当我尝试使用 nx.connected_component_subgraphs(G) 时,我收到以下给定的错误。请帮助解决这个问题。
在数据集中有两个 couns(电影和演员),它是二部图的形式。
我想获得电影节点的连接组件。
----> 1 A = list(nx.connected_component_subgraphs(B))[0]中的AttributeError Traceback(最近一次调用)
AttributeError: 模块“networkx”没有属性“connected_component_subgraphs”
小智 8
connected_component_subgraphs
已从 networkx 库中删除。您可以使用弃用通知中描述的替代方法。
对于您的示例,请参考以下代码:
A = (B.subgraph(c) for c in nx.connected_components(B))
A = list(A)[0]
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
10045 次 |
最近记录: |