Code covered by the BSD License  

Highlights from
Matgraph

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

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

path

PURPOSE ^

path(g,n) --- make g a path on n vertices

SYNOPSIS ^

function path(g,n)

DESCRIPTION ^

 path(g,n) --- make g a path on n vertices

CROSS-REFERENCE INFORMATION ^

This function calls:
  • add add --- add edge(s) to the graph
  • embed embed --- create an embedding for a graph
  • hasxy hasxy(g) --- determine if an embedding has been created for g
  • resize resize(g,n) --- change the number of vertices in g to n
  • rmxy rmxy(g) --- erase g's embedding
This function is called by:
  • cube cube(g,k) --- create a k-cube (default k = 3)
  • cycle cycle(g,n) --- create a cycle graph on n vertices
  • hamiltonian_cycle hamiltonian_cycle(g) --- find a Hamiltonian cycle in g (if one exists)

SOURCE CODE ^

0001 function path(g,n)
0002 % path(g,n) --- make g a path on n vertices
0003 
0004 global GRAPH_MAGIC
0005 
0006 if hasxy(g)
0007     rmxy(g)
0008 end
0009 
0010 resize(g,0);
0011 resize(g,n);
0012 
0013 for k=1:n-1
0014     add(g,k,k+1);
0015 end
0016 
0017 x = 0:n-1;
0018 y = zeros(1,n);
0019 xy = [x',y'];
0020 
0021 embed(g,xy);

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

Contact us at files@mathworks.com