第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

AttributeError:模塊“networkx”沒有屬性

AttributeError:模塊“networkx”沒有屬性

HUWWW 2022-10-06 16:14:32
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)。在數(shù)據(jù)集中有兩個庫(電影和演員),它的形式是二分圖。我想獲得電影節(jié)點的連接組件。---------------------------------------------------------------------------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'
查看完整描述

4 回答

?
慕神8447489

TA貢獻1780條經(jīng)驗 獲得超1個贊

這在 2.1 版中已被棄用,最終在 2.4 版中被刪除。

請參閱這些說明

利用(G.subgraph(c) for c in connected_components(G))

或者(G.subgraph(c).copy() for c in connected_components(G))


查看完整回答
反對 回復(fù) 2022-10-06
?
呼喚遠方

TA貢獻1856條經(jīng)驗 獲得超11個贊

connected_component_subgraphs 已從 networkx 庫中刪除。您可以使用棄用通知中描述的替代方法。

對于您的示例,請參閱以下代碼:

A = (B.subgraph(c) for c in nx.connected_components(B))
A = list(A)[0]


查看完整回答
反對 回復(fù) 2022-10-06
?
月關(guān)寶盒

TA貢獻1772條經(jīng)驗 獲得超5個贊

使用以下代碼進行單行替代

A=list(B.subgraph(c) for c in nx.connected_components(B))[0]

或者你可以安裝以前版本的networkx

pip install networkx==2.3


查看完整回答
反對 回復(fù) 2022-10-06
?
Helenr

TA貢獻1780條經(jīng)驗 獲得超4個贊

首先我得到

AttributeError:模塊“matplotlib.cbook”沒有屬性“iterable”。

為了解決上述錯誤,我升級了 networkx 使用

pip install --upgrade --force-reinstall  network

它安裝了 unetworkx-2.6.3,我得到了錯誤

AttributeError:模塊 networkx 沒有屬性 connected_component_subgraphs。

我使用了 ABHISHEK D 提到的以下代碼,它解決了。謝謝。

A=list(B.subgraph(c) for c in nx.connected_components(B))[0]


查看完整回答
反對 回復(fù) 2022-10-06
  • 4 回答
  • 0 關(guān)注
  • 570 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號