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)
时,出现了下面给出的错误。
在数据集中有两列(电影和演员),它们形成一个二分图。
我想要获取电影节点的连通分量。
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-16-efff4e6fafc4> in <module>
----> 1 A = list(nx.connected_component_subgraphs(B))[0]
AttributeError: module 'networkx' has no attribute 'connected_component_subgraphs'
nx.__version__
中获取了什么? - yatunx.connected_component_subgraphs
。 - yatu