2017-10-30 5 views
0

私はnetworkxを使ってコミュニティ分析をしようとしています。AttributeError:module 'networkx.algorithms.community'に属性がありません 'girvan_newman'

エラーはmodule 'networkx.algorithms.community' has no attribute 'girvan_newman'です。 私のpythonバージョンは3.6、networkxバージョン2.0です。

は、ここに私のコードです:

import networkx as nx 
from networkx.algorithms import community 
G = nx.barbell_graph(5, 1) 
communities_generator = community.girvan_newman(G) 
top_level_communities = next(communities_generator) 
next_level_communities = next(communities_generator) 
sorted(map(sorted, next_level_communities)) 

答えて

2

function you're looking forはあなたが持っているものとは少し異なる名前空間です。

from networkx.algorithms.community.centrality import girvan_newman 

注欠けていた名前空間のcentrality一部を次のようにあなたはそれをインポートする必要があります。

関連する問題