AttributeError: module 'networkx' has no attribute 'from_numpy_matrix'


A is co occurrence dataframe. Why it shown AttributeError: module ‘networkx’ has no attribute ‘from_numpy_matrix’

import numpy as np
import networkx as nx
import matplotlib
Asked By: Pranab



In networkx 3.0 the changelog shows the following "Remove to_numpy_matrix & from_numpy_matrix (#5746)"

You have to downgrade networkx or use G=nx.from_numpy_array(A) instead.

Answered By: tetris programming

You can use G = nx.DiGraph(np.array(A)) instead of G = nx.from_numpy_matrix(np.array(A), create_using=nx.Graph)

Answered By: user18638189
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.