NetworkX

Previous topic

networkx.convert.to_scipy_sparse_matrix

Next topic

Reading and writing graphs

networkx.convert.from_scipy_sparse_matrix

from_scipy_sparse_matrix(A, create_using=None)

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()

Examples

>>> import scipy.sparse
>>> A=scipy.sparse.eye(2,2,1)
>>> G=nx.from_scipy_sparse_matrix(A)