circulant(g,n,k) --- overwrite g with an n,k circulant graph
SYNOPSIS
function circulant(g,n,k)
DESCRIPTION
circulant(g,n,k) --- overwrite g with an n,k circulant graph
g has n vertices {1,2,...,n}. Each vertex has an edge to the next k in
line. So this is a 2k regular graph.
clear_edges clear_edges(g) --- delete all edges of g
resize resize(g,n) --- change the number of vertices in g to n
This function is called by:
SOURCE CODE
0001 function circulant(g,n,k)
0002 % circulant(g,n,k) --- overwrite g with an n,k circulant graph
0003 % g has n vertices {1,2,...,n}. Each vertex has an edge to the next k in
0004 % line. So this is a 2k regular graph.
0005
0006 resize(g,n);
0007 clear_edges(g);
0008
0009 for u=1:n
0010 for uu=[u+1:u+k]
0011 v = mod(uu,n);
0012 if (v==0)
0013 v = n;
0014 end
0015 add(g,u,v);
0016 end
0017 end