Home > matgraph > @graph > mobius.m

mobius

PURPOSE ^

mobius(g,nverts) --- create a Mobius ladder graph

SYNOPSIS ^

function mobius(g,nverts)

DESCRIPTION ^

 mobius(g,nverts) --- create a Mobius ladder graph
 g is the graph to be written
 nverts is the number of vertices (must be even)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function mobius(g,nverts)
0002 % mobius(g,nverts) --- create a Mobius ladder graph
0003 % g is the graph to be written
0004 % nverts is the number of vertices (must be even)
0005 
0006 
0007 if (mod(nverts,2)==1)
0008     error('Number of vertices must be even')
0009 end
0010 if (nverts < 6)
0011     error('Number of vertices must be at least 6')
0012 end
0013 
0014 n = nverts/2;
0015 cycle(g,nverts)
0016 more_edges = zeros(n,2);
0017 for v=1:n
0018     more_edges(v,:) = [v, v+n];
0019 end
0020 
0021 add(g,more_edges);
0022 
0023 % create an embedding
0024 rmxy(g);
0025 
0026 % inner ring of vertices
0027 t = (0:n-1)*2*pi/n;
0028 x = n * cos(t)/6;
0029 y = n * sin(t)/6;
0030 xy1 = [x',y'];
0031 
0032 % outer ring of vertices
0033 x = (n+6)*cos(t)/6;
0034 y = (n+6)*sin(t)/6;
0035 xy2 = [x',y'];
0036 
0037 xy = [xy1;xy2];
0038 
0039 % rotate slightly so crossing is symmetric across the x-axis
0040 theta = pi/n;
0041 ct = cos(theta);
0042 st = sin(theta);
0043 rot = [ct,st; -st, ct];
0044 xy = xy*rot;
0045 
0046 embed(g,xy);

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