Skip to content

Commit 245c661

Browse files
author
Emden Gansner
committed
Update man page, and fix number of nodes in the 2D Sierpinski graph;
fix edge count for 3D Sierpinski in graph_generator.c; modify CLI to use -S for Sierpinski in any dimension.
1 parent e4ad574 commit 245c661

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

cmd/tools/graph_generator.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ void makeTetrix(int depth, edgefn ef)
393393
depth--;
394394
n = 4 + 2 * (((int) (pow(4.0, (double) depth) + 0.5) - 1));
395395

396-
nedges = (int) (pow(6.0, depth + 1.0) + 0.5);
396+
nedges = 6 * (int) (pow(4.0, depth) + 0.5);
397397

398398
graph = N_NEW(n + 1, vtx_data);
399399
edges = N_NEW(6 * n, int);

cmd/tools/gvgen.1

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ gvgen \- generate graphs
5555
.BI -S n
5656
]
5757
[
58+
.BI -S n,d
59+
]
60+
[
5861
.BI -t n
5962
]
6063
[
@@ -154,9 +157,15 @@ This will have \fIn-1\fP edges.
154157
.TP
155158
.BI \-S " n"
156159
Generate a Sierpinski graph of order \fIn\fP.
157-
This will have \fI3*(3^(n-1) - 1)/2\fP vertices and
160+
This will have \fI3*(3^(n-1) + 1)/2\fP vertices and
158161
\fI3^n\fP edges.
159162
.TP
163+
.BI \-S " n,d"
164+
Generate a \fId\fP-dimensional Sierpinski graph of order \fIn\fP.
165+
At present, \fId\fP must be 2 or 3.
166+
For d equal to 3, there will be \fI4*(4^(n-1) + 1)/2\fP vertices and
167+
\fI6 * 4^(n-1)\fP edges.
168+
.TP
160169
.BI \-t " n"
161170
Generate a binary tree of height \fIn\fP.
162171
This will have \fI2^n-1\fP vertices and

cmd/tools/gvgen.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
typedef enum { unknown, grid, circle, complete, completeb,
3636
path, tree, torus, cylinder, mobius, randomg, randomt, ball,
37-
sierpinski, tetrix, hypercube, star, wheel, trimesh
37+
sierpinski, hypercube, star, wheel, trimesh
3838
} GraphType;
3939

4040
typedef struct {
@@ -91,8 +91,8 @@ static char *Usage = "Usage: %s [-dv?] [options]\n\
9191
-r<x>,<n> : random graph\n\
9292
-R<n> : random rooted tree on <n> vertices\n\
9393
-s<x> : star\n\
94-
-S<x> : sierpinski\n\
95-
-X<x> : tetrix (3d sierpinski)\n\
94+
-S<x> : 2D sierpinski\n\
95+
-S<x>,<d> : <d>D sierpinski (<d> = 2,3)\n\
9696
-t<x> : binary tree \n\
9797
-t<x>,<n> : n-ary tree \n\
9898
-T<x,y> : torus \n\
@@ -375,14 +375,13 @@ static GraphType init(int argc, char *argv[], opts_t* opts)
375375
break;
376376
case 'S':
377377
graphType = sierpinski;
378-
if (setOne(optarg, opts))
378+
if (setTwoOpt(optarg, opts, 2))
379379
errexit(c);
380-
break;
381-
case 'X':
382-
graphType = tetrix;
383-
if (setOne(optarg, opts))
380+
if (opts->graphSize2 > 3) {
381+
fprintf(stderr, "%dD Sierpinski not implemented - use 2 or 3 ", opts->graphSize2);
384382
errexit(c);
385-
break;
383+
}
384+
break;
386385
case 's':
387386
graphType = star;
388387
if (setOne(optarg, opts))
@@ -513,10 +512,10 @@ int main(int argc, char *argv[])
513512
makeMobius(opts.graphSize1, opts.graphSize2, ef);
514513
break;
515514
case sierpinski:
516-
makeSierpinski(opts.graphSize1, ef);
517-
break;
518-
case tetrix:
519-
makeTetrix(opts.graphSize1, ef);
515+
if (opts.graphSize2 == 2)
516+
makeSierpinski(opts.graphSize1, ef);
517+
else
518+
makeTetrix(opts.graphSize1, ef);
520519
break;
521520
case complete:
522521
makeComplete(opts.graphSize1, ef);

0 commit comments

Comments
 (0)