.BI -w n
]
[
+.BI -n prefix
+]
+[
+.BI -N name
+]
+[
.BI -o outfile
]
.SH DESCRIPTION
Generate a path on \fIn\fP vertices.
This will have \fIn-1\fP edges.
.TP
+.BI \-n " prefix"
+Normally, integers are used as node names. If \fIprefix\fP is specified,
+this will be prepended to the integer to create the name.
+.TP
+.BI \-N " name"
+Use \fIname\fP as the name of the graph.
+By default, the graph is anonymous.
+.TP
.BI \-o " outfile"
If specified, the generated graph is written into the file
.I outfile.
int foldVal;
int directed;
FILE *outfile;
+ char* pfx;
+ char* name;
} opts_t;
static char *cmd;
-h<x> : hypercube \n\
-k<x> : complete \n\
-b<x,y> : complete bipartite\n\
+ -n<prefix> : use <prefix> in node names (\"\")\n\
+ -N<name> : use <name> for the graph (\"\")\n\
-o<outfile> : put output in <outfile> (stdout)\n\
-p<x> : path \n\
-s<x> : star\n\
return next;
}
-static char *optList = ":c:C:dg:G:h:k:b:o:p:s:S:t:T:Vw:";
+static char *optList = ":n:N:c:C:dg:G:h:k:b:o:p:s:S:t:T:Vw:";
static GraphType init(int argc, char *argv[], opts_t* opts)
{
if (setTwo(optarg, opts))
errexit(c);
break;
+ case 'n':
+ opts->pfx = optarg;
+ break;
+ case 'N':
+ opts->name = optarg;
+ break;
case 'o':
opts->outfile = openFile(optarg, "w");
break;
static void dirfn (int t, int h)
{
if (h > 0)
- fprintf (opts.outfile, " %d -> %d\n", t, h);
+ fprintf (opts.outfile, " %s%d -> %s%d\n", opts.pfx, t, opts.pfx, h);
else
- fprintf (opts.outfile, " %d\n", t);
+ fprintf (opts.outfile, " %s%d\n", opts.pfx, t);
}
static void undirfn (int t, int h)
{
if (h > 0)
- fprintf (opts.outfile, " %d -- %d\n", t, h);
+ fprintf (opts.outfile, " %s%d -- %s%d\n", opts.pfx, t, opts.pfx, h);
else
- fprintf (opts.outfile, " %d\n", t);
+ fprintf (opts.outfile, " %s%d\n", opts.pfx, t);
}
int main(int argc, char *argv[])
{
- GraphType graphType = init(argc, argv, &opts);
+ GraphType graphType;
edgefn ef;
+ opts.pfx = "";
+ opts.name = "";
+ graphType = init(argc, argv, &opts);
if (opts.directed) {
fprintf(opts.outfile, "digraph {\n");
ef = dirfn;