在我學(xué)習(xí)louvain算法時(shí),運(yùn)行了這樣一段代碼
from communities.algorithms import louvain_method
from communities.visualization import draw_communities
import numpy as np
adj_matrix = np.array([[0, 1, 1, 0, 0, 0],
[1, 0, 1, 0, 0, 0],
[1, 1, 0, 1, 0, 0],
[0, 0, 1, 0, 1, 1],
[0, 0, 0, 1, 0, 1],
[0, 0, 0, 1, 1, 0]])
communities, frames = louvain_method(adj_matrix)
draw_communities(adj_matrix, communities)
運(yùn)行報(bào)錯(cuò)
AttributeError: module 'networkx' has no attribute 'from_numpy_matrix'
問(wèn)題原因及解決方案:文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-507126.html
在 .networkx 3.0 中,變更日志顯示以下內(nèi)容“刪to_numpy_matrix
?&?from_numpy_matrix
?(#5746)”?https:/.networkx.org/documentation/stable/release/release_3.0.html您必須降級(jí).networkx 或改用G=nx.from_numpy_array(A)
?。?https:/.networkx.org/documentation/stable/reference/readwrite/matrix_market.html文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-507126.html
到了這里,關(guān)于AttributeError: module ‘networkx‘ has no attribute ‘from_numpy_matrix‘解決方法的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!