Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

laplacian_matrix

laplacian_matrix(G, nodelist=None, weight='weight')[source]

Return the Laplacian matrix of G.

The graph Laplacian is the matrix L = D - A, where A is the adjacency matrix and D is the diagonal matrix of node degrees.

Parameters :

G : graph

A NetworkX graph

nodelist : list, optional

The rows and columns are ordered according to the nodes in nodelist. If nodelist is None, then the ordering is produced by G.nodes().

weight : string or None, optional (default=’weight’)

The edge data key used to compute each value in the matrix. If None, then each edge has weight 1.

Returns :

L : SciPy sparse matrix

The Laplacian matrix of G.

See also

to_numpy_matrix, normalized_laplacian_matrix

Notes

For MultiGraph/MultiDiGraph, the edges weights are summed.