This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.


Graph Laplacian matrix


L = laplacian(G)



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.


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 = 
   (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 = 
   All zero sparse: 6x6

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.

Introduced in R2015b