laplacian(g) --- get the Laplacian matrix of g equal to D-A where A is the adjacency matrix and D is a diagonal matrix of the degrees of the vertices.
0001 function m = laplacian(g) 0002 % laplacian(g) --- get the Laplacian matrix of g 0003 % equal to D-A where A is the adjacency matrix and D is a diagonal matrix 0004 % of the degrees of the vertices. 0005 0006 0007 n = nv(g); 0008 d = deg(g); 0009 m = -matrix(g); 0010 for k=1:n 0011 m(k,k) = d(k); 0012 end