Warning
This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.
from_scipy_sparse_matrix¶
- from_scipy_sparse_matrix(A, create_using=None, edge_attribute='weight')[source]¶
Return a graph from scipy sparse matrix adjacency list.
Parameters : A: scipy sparse matrix
An adjacency matrix representation of a graph
create_using: NetworkX graph
Use specified graph for result. The default is Graph()
edge_attribute: string
Name of edge attrbute to store matrix numeric value. The data will have the same type as the matrix entry (int, float, (real,imag)).
Examples
>>> import scipy.sparse >>> A = scipy.sparse.eye(2,2,1) >>> G = nx.from_scipy_sparse_matrix(A)