Home > matgraph > @graph > subsref.m

subsref

PURPOSE ^

subsref implements the notation g(v) and g(v,w)

SYNOPSIS ^

function nvec = subsref(g,S)

DESCRIPTION ^

 subsref implements the notation g(v) and g(v,w)
 g(v) --- returns the neighbor set of v
 g(v,w) --- returns 1 if v and w are adjacent and 0 otherwise

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function nvec = subsref(g,S)
0002 % subsref implements the notation g(v) and g(v,w)
0003 % g(v) --- returns the neighbor set of v
0004 % g(v,w) --- returns 1 if v and w are adjacent and 0 otherwise
0005 
0006 global GRAPH_MAGIC
0007 
0008 args = S.subs;
0009 n = nv(g);
0010 
0011 % single subscript case
0012 
0013 if length(args)==1
0014     v = args(1);
0015     v = v{1};
0016     nvec = neighbors(g,v);
0017     return
0018 end
0019 
0020 % two subscript case
0021 
0022 v = args(1);
0023 v = v{1};
0024 w = args(2);
0025 w = w{1};
0026 
0027 if (v<0) | (v>n) | (w<0) | (w>n) | (v==w)
0028     nvec = logical(0);
0029 else
0030     nvec = GRAPH_MAGIC.graphs{g.idx}.array(v,w);
0031     nvec = full(nvec);
0032 end

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