Main Content

laplacian

Graph Laplacian matrix

Description

example

L= laplacian(G)returns the graph Laplacian matrix,L. Each diagonal entry,L(j,j), is given by the degree of nodej,degree(G,j). The off-diagonal entries ofLrepresent the edges inGsuch thatL(i,j) = L(j,i) = -1if there is an edge between nodesiandj; otherwise,L(i,j) = L(j,i) = 0. The input graphGcannot be a multigraph or contain self-loops, and edge weights are ignored.

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 = (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 ofLindicate the degree of the nodes, such thatL(j,j)is the degree of nodej.

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

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

Input Arguments

collapse all

Input graph, specified as agraphobject. Usegraphto create an undirected graph object.

Example:G = graph(1,2)

Output Arguments

collapse all

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

版本历史

Introduced in R2015b