Code covered by the BSD License  

Highlights from
Matgraph

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

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

trim

PURPOSE ^

trim(g,d) --- iteratively remove vertices of degree at most d

SYNOPSIS ^

function trim(g,d)

DESCRIPTION ^

 trim(g,d) --- iteratively remove vertices of degree at most d

CROSS-REFERENCE INFORMATION ^

This function calls:
  • deg deg: degree of a vertex or degree sequence
  • delete delete --- delete vertices or edges from a graph
  • nv nv(g) --- number of vertices in g
This function is called by:

SOURCE CODE ^

0001 function trim(g,d)
0002 % trim(g,d) --- iteratively remove vertices of degree at most d
0003 
0004 if nargin==1
0005     d = 0;
0006 end
0007 
0008 ds = deg(g);
0009 x = find(ds <= d);
0010 x=x';
0011 while (length(x) > 0)
0012     if (nv(g) == 0)
0013         return
0014     end
0015     delete(g,x);
0016     ds = deg(g);
0017     x = find(ds <= d);
0018     x=x';
0019 end

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

Contact us at files@mathworks.com