AttributeError:模块"networkx"没有属性"connected_component_subgraphs" [英] AttributeError: module 'networkx' has no attribute 'connected_component_subgraphs'

查看:174
本文介绍了AttributeError:模块"networkx"没有属性"connected_component_subgraphs"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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]

尝试使用nx.connected_component_subgraphs(G)时出现以下给定错误.请帮助解决此问题.

I am getting the below given error when am trying to use nx.connected_component_subgraphs(G). Please help with this issue.

数据集中有两个列(电影和演员),形式为二部图.

In the dataset there are two coumns(movie and actor), and it's in the form bipartite graph.

我想获得电影节点的连接组件.

I want to get connected components for the movie nodes.

AttributeError跟踪(最近一次呼叫最近)在----> 1 A =列表(nx.connected_component_subgraphs(B))[0]

AttributeError Traceback (most recent call last) in ----> 1 A = list(nx.connected_component_subgraphs(B))[0]

AttributeError:模块'networkx'没有属性'connected_component_subgraphs'

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

推荐答案

此版本在2.1版中已弃用,最后在2.4版中被删除.

This was deprecated with version 2.1, and finally removed with version 2.4.

请参见这些说明

使用(connected_components(G)中c的G.subgraph(c))

(connected_components(G)中c的G.subgraph(c).copy())

这篇关于AttributeError:模块"networkx"没有属性"connected_component_subgraphs"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆