Code covered by the BSD License  

Highlights from
Matgraph

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

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

neighbors

PURPOSE ^

neighbors(g,v) --- neighbors of v as a list.

SYNOPSIS ^

function nlist = neighbors(g,v)

DESCRIPTION ^

 neighbors(g,v) --- neighbors of v as a list.
 Note: invoking g(v) has the same effect.

CROSS-REFERENCE INFORMATION ^

This function calls:
  • nv nv(g) --- number of vertices in g
This function is called by:
  • bfstree bfstree(t,g,v) --- create a breadth-first spanning tree of g
  • color color(g,algo) --- color the graph g by a given algorithm
  • contract contract(g,u,v) --- contract v into u
  • dfstree dfstree(t,g,v) --- create a depth-first spanning tree of g
  • euler_trail euler_trail(g) --- find an euler trail in g (if one exists)
  • find_path find_path(g,u,v) --- find a shortest path from u to v
  • hamiltonian_cycle hamiltonian_cycle(g) --- find a Hamiltonian cycle in g (if one exists)
  • iso [yn,p] = iso(g,h,options) --- is g isomorphic to h?
  • nauty nauty(g,filename) -- save a graph in nauty format
  • prufer prufer --- convert a tree to/from its Prufer code
  • subsref subsref implements the notation g(v) and g(v,w)
  • vertex_degree_sequence find the degrees of the neighbors of a vertex

SOURCE CODE ^

0001 function nlist = neighbors(g,v)
0002 % neighbors(g,v) --- neighbors of v as a list.
0003 % Note: invoking g(v) has the same effect.
0004 
0005 global GRAPH_MAGIC
0006 
0007 n = nv(g);
0008 if (v<0) | (v>n)
0009     nlist = [];
0010 else
0011     nlist = find(GRAPH_MAGIC.graphs{g.idx}.array(v,:));
0012 end

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

Contact us at files@mathworks.com