nsptrees(g) --- number of spanning trees of g. This computes the number of spanning trees of g using the matrix-tree theorem.
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));