A是共现矩阵。为什么会出现AttributeError: module 'networkx' has no attribute 'from_numpy_matrix'的错误。
import numpy as np
import networkx as nx
import matplotlib
A=np.matrix(coocc)
G=nx.from_numpy_matrix(A)
A是共现矩阵。为什么会出现AttributeError: module 'networkx' has no attribute 'from_numpy_matrix'的错误。
import numpy as np
import networkx as nx
import matplotlib
A=np.matrix(coocc)
G=nx.from_numpy_matrix(A)
to_numpy_matrix
和from_numpy_matrix
(#5746)”。您必须降级networkx或使用G=nx.from_numpy_array(A)
代替。https://networkx.org/documentation/stable/release/release_3.0.htmlhttps://networkx.org/documentation/stable/reference/readwrite/matrix_market.html。您可以使用 G = nx.DiGraph(np.array(A))
替代 G = nx.from_numpy_matrix(np.array(A), create_using=nx.Graph)
adj_matrix = nx.to_numpy_array(sm)
- undefinedadj_matrix = nx.to_numpy_array(sm)
。 - blacksnail789521