I\'m trying to get into creating network graphs and generating sparse matrices from them. From the wikipedia Laplacian matrix
example, I decided to try and recreat
I was confronted with the same problem, and found a solution. We can use the function from_numpy_matrix, which is depicted in official website http://networkx.github.io/documentation/networkx-1.7/reference/generated/networkx.convert.from_numpy_matrix.html. Pay attention that the input data usually needs to be modified by numpy.matrix(). The example given is that:
import numpy
A=numpy.matrix([[1,1],[2,1]])
G=nx.from_numpy_matrix(A)
It's really useful.