NetworkX

Previous topic

networkx.to_numpy_matrix

Next topic

networkx.to_scipy_sparse_matrix

networkx.from_numpy_matrix

from_numpy_matrix(A, create_using=None)

Return a graph from numpy matrix adjacency list.

Parameters:

A : numpy matrix

An adjacency matrix representation of a graph

create_using : NetworkX graph

Use specified graph for result. The default is Graph()

Examples

>>> import numpy
>>> A=numpy.matrix([[1,1],[2,1]])
>>> G=nx.from_numpy_matrix(A)