Code covered by the BSD License  

Highlights from
Matgraph

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

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

nsptrees

PURPOSE ^

nsptrees(g) --- number of spanning trees of g.

SYNOPSIS ^

function nt = nsptrees(g)

DESCRIPTION ^

 nsptrees(g) --- number of spanning trees of g.
 This computes the number of spanning trees of g using the matrix-tree
 theorem.

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:

SOURCE CODE ^

0001 function nt = nsptrees(g)
0002 % nsptrees(g) --- number of spanning trees of g.
0003 % This computes the number of spanning trees of g using the matrix-tree
0004 % theorem.
0005 
0006 A = diag(deg(g)) - matrix(g);
0007 n = nv(g)-1;
0008 nt = det(A(1:n,1:n));

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

Contact us at files@mathworks.com