Code covered by the BSD License  

Highlights from
Matgraph

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

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

has

PURPOSE ^

has --- check if the graph has a particular vertex or edge

SYNOPSIS ^

function yn = has(g,u,v)

DESCRIPTION ^

 has --- check if the graph has a particular vertex or edge
 has(g,u) --- check if g contains the vertex u
 has(g,u,v) --- check if g contains the edge uv

CROSS-REFERENCE INFORMATION ^

This function calls:
  • nv nv(g) --- number of vertices in g
This function is called by:
  • bridges bridges(g,algo) --- find all cut edges in g
  • cartesian cartesian(g,h1,h2) --- overwrite g with the product of h1 and h2
  • hamiltonian_cycle hamiltonian_cycle(g) --- find a Hamiltonian cycle in g (if one exists)
  • springxy springxy(g) --- find a spring embedding of g

SOURCE CODE ^

0001 function yn = has(g,u,v)
0002 % has --- check if the graph has a particular vertex or edge
0003 % has(g,u) --- check if g contains the vertex u
0004 % has(g,u,v) --- check if g contains the edge uv
0005 
0006 global GRAPH_MAGIC;
0007 n = nv(g);
0008 
0009 if (nargin==1)
0010     yn = (u>0) & (u<=n)
0011 else
0012     if (u<0) | (u>n) | (v<0) | (v>n) | (u==v)
0013         yn = 0;
0014     else
0015         yn = GRAPH_MAGIC.graphs{g.idx}.array(u,v);
0016     end
0017 end

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

Contact us at files@mathworks.com