56static char *
Usage =
"Usage: %s [-dv?] [options]\n\
58 -C<x,y> : cylinder \n\
59 -g[f]<h,w> : grid (folded if f is used)\n\
60 -G[f]<h,w> : partial grid (folded if f is used)\n\
63 -b<x,y> : complete bipartite\n\
65 -i<n> : generate <n> random\n\
66 -m<x> : triangular mesh\n\
67 -M<x,y> : x by y Moebius strip\n\
68 -n<prefix> : use <prefix> in node names (\"\")\n\
69 -N<name> : use <name> for the graph (\"\")\n\
70 -o<outfile> : put output in <outfile> (stdout)\n\
72 -r<x>,<n> : random graph\n\
73 -R<n> : random rooted tree on <n> vertices\n\
75 -S<x> : 2D sierpinski\n\
76 -S<x>,<d> : <d>D sierpinski (<d> = 2,3)\n\
77 -t<x> : binary tree \n\
78 -t<x>,<n> : n-ary tree \n\
80 -T<x,y,t1,t2> : twisted torus \n\
81 -u<seed> : state for random number generation\n\
83 -d : directed graph\n\
89 fprintf(v ? stderr : stdout,
Usage,
cmd);
94 fprintf(stderr,
"in flag -%c\n", (
char)opt);
104 static const unsigned MIN = 1;
106 const unsigned long d = strtoul(
s, e, 10);
107 if (
s == *e || d > UINT_MAX) {
108 fprintf(stderr,
"ill-formed integer \"%s\" ",
s);
112 fprintf(stderr,
"integer \"%s\" less than %d",
s,
MIN);
151 fprintf(stderr,
"ill-formed int pair \"%s\" ",
s);
178 fprintf(stderr,
"ill-formed int pair \"%s\" ",
s);
248static 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:";
257 while ((c = getopt(argc, argv,
optList)) != -1) {
340 fprintf(stderr,
"%uD Sierpinski not implemented - use 2 or 3 ",
380 fprintf(stderr,
"Unrecognized flag \"-%c\" - ignored\n",
384 fprintf(stderr,
"Unexpected error\n");
394 fprintf(stderr,
"Graph type not set\n");
403static void dirfn(
unsigned t,
unsigned h) {
426int main(
int argc,
char *argv[])
498 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)