Attributeerror: Module 'Networkx' Has No Attribute 'From_Numpy_Matrix'

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
A=np.matrix(coocc)
G=nx.from_numpy_matrix(A)

3 Answers

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.

1

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

Use nx.from_numpy_array(.) instead!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Sarah Jenkins
Author

Sarah Jenkins

Sarah Jenkins is a veteran tech journalist with over 12 years of experience covering artificial intelligence, mobile innovations, and digital ethics. Her insights have appeared in leading technology publications worldwide.