Home > matgraph > @graph > isconnected.m

isconnected

PURPOSE ^

isconnected(g) --- test if g is a connected graph

SYNOPSIS ^

function yn = isconnected(g)

DESCRIPTION ^

 isconnected(g) --- test if g is a connected graph

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function yn = isconnected(g)
0002 % isconnected(g) --- test if g is a connected graph
0003 
0004 global GRAPH_MAGIC
0005 
0006 n = nv(g);
0007 if (n==0) 
0008     yn = 1;
0009     return
0010 end
0011 
0012 x = zeros(n,1);
0013 x(1) = 1;
0014 while(1)
0015     y = x;
0016     x = GRAPH_MAGIC.graphs{g.idx}.array*x + x;
0017     x = double(x>0);
0018     if (x==y)
0019         break
0020     end
0021 end
0022 
0023 yn = sum(x)==n;

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