www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/GraphLaplacianMatrixExample.m

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

% Copyright 2015 The MathWorks, Inc.

s = [1 1 1 1 1];
t = [2 3 4 5 6];
G = graph(s,t);
L = laplacian(G)

%%
% 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'