scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
laplacian(csgraph, normed=False, return_diag=False, use_out_degree=False)

Notes

The Laplacian matrix of a graph is sometimes referred to as the "Kirchoff matrix" or the "admittance matrix", and is useful in many parts of spectral graph theory. In particular, the eigen-decomposition of the laplacian matrix can give insight into many properties of the graph.

Parameters

csgraph : array_like or sparse matrix, 2 dimensions

compressed-sparse graph, with shape (N, N).

normed : bool, optional

If True, then compute symmetric normalized Laplacian.

return_diag : bool, optional

If True, then also return an array related to vertex degrees.

use_out_degree : bool, optional

If True, then use out-degree instead of in-degree. This distinction matters only if the graph is asymmetric. Default: False.

Returns

lap : ndarray or sparse matrix

The N x N laplacian matrix of csgraph. It will be a NumPy array (dense) if the input was dense, or a sparse matrix otherwise.

diag : ndarray, optional

The length-N diagonal of the Laplacian matrix. For the normalized Laplacian, this is the array of square roots of vertex degrees or 1 if the degree is zero.

Return the Laplacian matrix of a directed graph.

Examples

>>> from scipy.sparse import csgraph
... G = np.arange(5) * np.arange(5)[:, np.newaxis]
... G array([[ 0, 0, 0, 0, 0], [ 0, 1, 2, 3, 4], [ 0, 2, 4, 6, 8], [ 0, 3, 6, 9, 12], [ 0, 4, 8, 12, 16]])
>>> csgraph.laplacian(G, normed=False)
array([[  0,   0,   0,   0,   0],
       [  0,   9,  -2,  -3,  -4],
       [  0,  -2,  16,  -6,  -8],
       [  0,  -3,  -6,  21, -12],
       [  0,  -4,  -8, -12,  24]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.sparse.csgraph._laplacian.laplacian

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/sparse/csgraph/_laplacian.py#16
type: <class 'function'>
Commit: