Main Content

laplacian

Graph Laplacian matrix

Description

L = laplacian(G) returns the graph Laplacian matrix, L. Each diagonal entry, L(j,j), is given by the degree of node j, degree(G,j). The off-diagonal entries of L represent the edges in G such that L(i,j) = L(j,i) = -1 if there is an edge between nodes i and j; otherwise, L(i,j) = L(j,i) = 0. The input graph G cannot be a multigraph or contain self-loops, and edge weights are ignored.

example

Examples

collapse all

Create a graph using an edge list, and then calculate the graph Laplacian matrix.

s = [1 1 1 1 1];
t = [2 3 4 5 6];
G = graph(s,t);
L = laplacian(G)
L = 6x6 sparse double matrix (16 nonzeros)
   (1,1)        5
   (2,1)       -1
   (3,1)       -1
   (4,1)       -1
   (5,1)       -1
   (6,1)       -1
   (1,2)       -1
   (2,2)        1
   (1,3)       -1
   (3,3)        1
   (1,4)       -1
   (4,4)        1
   (1,5)       -1
   (5,5)        1
   (1,6)       -1
   (6,6)        1

The diagonal elements of L indicate the degree of the nodes, such that L(j,j) is the degree of node j.

Calculate the graph incidence matrix, I, and confirm the relation L = I*I'.

I = incidence(G);
L - I*I'
ans = 6x6 sparse double matrix
   All zero

Input Arguments

collapse all

Input graph, specified as a graph object. Use graph to create an undirected graph object.

Example: G = graph(1,2)

Output Arguments

collapse all

Laplacian matrix. L is a square, symmetric, sparse matrix of size numnodes(G)-by-numnodes(G). The graph Laplacian matrix is undefined for graphs with self-loops.

Extended Capabilities

Thread-Based Environment
Run code in the background using MATLAB® backgroundPool or accelerate code with Parallel Computing Toolbox™ ThreadPool.

Version History

Introduced in R2015b