Code covered by the BSD License  

Highlights from
Matgraph

from Matgraph by Ed Scheinerman
Toolbox for working with simple, undirected graphs

Description of laplacian
Home > matgraph > @graph > laplacian.m

laplacian

PURPOSE ^

laplacian(g) --- get the Laplacian matrix of g

SYNOPSIS ^

function m = laplacian(g)

DESCRIPTION ^

 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.

CROSS-REFERENCE INFORMATION ^

This function calls:
  • deg deg: degree of a vertex or degree sequence
  • matrix matrix(g) --- return (a copy of) the adjacency matrix of g
  • nv nv(g) --- number of vertices in g
This function is called by:
  • resistance R = resistance(g) --- calculate resistances between vertices
  • split part = split(g) --- partition the vertices of g into two subsets

SOURCE CODE ^

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

Generated on Thu 13-Mar-2008 14:23:52 by m2html © 2003

Contact us at files@mathworks.com