57static char *
Usage =
"Usage: %s [-dv?] [options]\n\
59 -C<x,y> : cylinder \n\
60 -g[f]<h,w> : grid (folded if f is used)\n\
61 -G[f]<h,w> : partial grid (folded if f is used)\n\
64 -b<x,y> : complete bipartite\n\
66 -i<n> : generate <n> random\n\
67 -m<x> : triangular mesh\n\
68 -M<x,y> : x by y Moebius strip\n\
69 -n<prefix> : use <prefix> in node names (\"\")\n\
70 -N<name> : use <name> for the graph (\"\")\n\
71 -o<outfile> : put output in <outfile> (stdout)\n\
73 -r<x>,<n> : random graph\n\
74 -R<n> : random rooted tree on <n> vertices\n\
76 -S<x> : 2D sierpinski\n\
77 -S<x>,<d> : <d>D sierpinski (<d> = 2,3)\n\
78 -t<x> : binary tree \n\
79 -t<x>,<n> : n-ary tree \n\
81 -T<x,y,t1,t2> : twisted torus \n\
82 -u<seed> : state for random number generation\n\
84 -d : directed graph\n\
90 fprintf(v ? stderr : stdout,
Usage,
cmd);
95 fprintf(stderr,
"in flag -%c\n", (
char)opt);
105 static const unsigned MIN = 1;
107 const unsigned long d = strtoul(
s, e, 10);
108 if (
s == *e || d > UINT_MAX) {
109 fprintf(stderr,
"ill-formed integer \"%s\" ",
s);
113 fprintf(stderr,
"integer \"%s\" less than %d",
s,
MIN);
152 fprintf(stderr,
"ill-formed int pair \"%s\" ",
s);
179 fprintf(stderr,
"ill-formed int pair \"%s\" ",
s);
249static char *
optList =
":i:M:m:n:N:c:C:dg:G:h:k:b:B:o:p:r:R:s:S:X:t:T:u:vw:";
258 while ((c = getopt(argc, argv,
optList)) != -1) {
292 const size_t max_shift =
sizeof(unsigned) * CHAR_BIT - 1;
294 fprintf(stderr,
"depth of a hypercube must be < %" PRISIZE_T "\n", max_shift);
348 fprintf(stderr,
"%uD Sierpinski not implemented - use 2 or 3 ",
363 const size_t max_shift =
sizeof(unsigned) * CHAR_BIT - 1;
365 fprintf(stderr,
"depth of a binary tree must be < %" PRISIZE_T "\n",
396 fprintf(stderr,
"Unrecognized flag \"-%c\" - ignored\n",
400 fprintf(stderr,
"Unexpected error\n");
408 fprintf(stderr,
"Graph type not set\n");
417static void dirfn(
unsigned t,
unsigned h) {
440int main(
int argc,
char *argv[])
449 graphType =
init(argc, argv, &
opts);
512 for (
unsigned i = 1; i <=
opts.
cnt; i++) {
static NORETURN void graphviz_exit(int status)
void makeTriMesh(unsigned sz, edgefn ef)
void makeHypercube(unsigned dim, edgefn ef)
void makeCircle(unsigned n, edgefn ef)
void makeTree(unsigned depth, unsigned nary, edgefn ef)
void makeWheel(unsigned n, edgefn ef)
void makeSquareGrid(unsigned dim1, unsigned dim2, int connect_corners, int partial, edgefn ef)
void makeBinaryTree(unsigned depth, edgefn ef)
void makeComplete(unsigned n, edgefn ef)
void makeMobius(unsigned w, unsigned h, edgefn ef)
treegen_t * makeTreeGen(unsigned N)
void makeCompleteB(unsigned dim1, unsigned dim2, edgefn ef)
void makeBall(unsigned w, unsigned h, edgefn ef)
void makePath(unsigned n, edgefn ef)
void makeTetrix(unsigned depth, edgefn ef)
void makeCylinder(unsigned dim1, unsigned dim2, edgefn ef)
void makeStar(unsigned n, edgefn ef)
void freeTreeGen(treegen_t *tg)
void makeTorus(unsigned dim1, unsigned dim2, edgefn ef)
void makeTwistedTorus(unsigned dim1, unsigned dim2, unsigned t1, unsigned t2, edgefn ef)
void makeRandomTree(treegen_t *tg, edgefn ef)
void makeRandom(unsigned h, unsigned w, edgefn ef)
void makeSierpinski(unsigned depth, edgefn ef)
static int setTwoTwoOpt(char *s, opts_t *opts, unsigned dflt)
static void dirfn(unsigned t, unsigned h)
static int setOne(char *s, opts_t *opts)
static int setTwoOpt(char *s, opts_t *opts, unsigned dflt)
static GraphType init(int argc, char *argv[], opts_t *opts)
static unsigned readPos(char *s, char **e)
static int readOne(char *s, unsigned *ip)
static int setTwo(char *s, opts_t *opts)
static void errexit(int opt)
static void closeOpen(void)
static char * setFold(char *s, opts_t *opts)
static void undirfn(unsigned t, unsigned h)
static const char * usage
static FILE * openFile(const char *argv0, const char *name, const char *mode)
unsigned seed
initial state for random number generator
void(* edgefn)(Agraph_t *, Agedge_t *, glCompColor)