#define HELPTEXT \ " Generate all graphs of a specified class.\n\
\n\
n : the number of vertices\n\
mine:maxe : a range for the number of edges\n\ #:0 means '# or more' except in the case 0:0\n\
res/mod : only generate subset res out of subsets 0..mod-1\n\
\n\
-c : only write connected graphs\n\
-C : only write biconnected graphs\n\
-t : only generate triangle-free graphs\n\
-f : only generate 4-cycle-free graphs\n\
-k : only generate K4-free graphs\n\
-T : only generate chordal graphs\n\
-S : only generate split graphs\n\
-P : only generate perfect graphs\n\
-F : only generate claw-free graphs\n\
-b : only generate bipartite graphs\n\
(-t, -f and -b can be used in any combination)\n\
-m : save memory at the expense of time (only makes a\n\
difference in the absence of -b, -t, -f and n <= 28).\n\
-d# : a lower bound for the minimum degree\n\
-D# : an upper bound for the maximum degree\n\
-v : display counts by number of edges\n\
-l : canonically label output graphs\n\
\n\
-u : donot output any graphs, just generate and count them\n\
-g : use graph6 output (default)\n\
-s : use sparse6 output\n\
-h : for graph6 or sparse6 format, write a header too\n\
\n\
-q : suppress auxiliary output (except from -v)\n\
\n\
See program text for much more information.\n"
/* Parameters:
n = the number of vertices (1..MAXN) Note that MAXN is limited to min(WORDSIZE,64) mine = the minimum number of edges (no bounds if missing) maxe = the maximum number of edges (same as mine if missing) 0 means "infinity" except in the case "0-0" mod, res = a way to restrict the output to a subset. All the graphs in G(n,mine..maxe) are divided into disjoint classes C(0,mod),C(1,mod),...,C(mod-1,mod), of very approximately equal size. Only the class C(res,mod) is written.
If the -x or -X switch is used, they must have the same value for different values of res; otherwise the partitioning may not be valid. In this case (-x,-X with constant value), the usual relationships between modulo classes are obeyed; for example C(3,4) = C(3,8) union C(7,8). This is not true if 3/8 and 7/8 are done with -x or -X values different from those used for 3/4.
file = a name for the output file (stdout if missing or "-")
All switches can be concatenated or separate. However, the value of -d must be attached to the "d", and similarly for "x".
-c : only write connected graphs -C : only write biconnected graphs -t : only generate triangle-free graphs -f : only generate 4-cycle-free graphs -b : only generate bipartite graphs (-t, -f and -b can be used in any combination) -m : save memory at expense of time (only makes a difference in the absence of -b, -t, -f and n <= 30). -D<int> : specify an upper bound for the maximum degree. The value of the upper bound must be adjacent to the "D". Example: -D6 -d<int> : specify a lower bound for the minimum degree. The value of the upper bound must be adjacent to the "d". Example: -d6 -v : display counts by number of edges -l : canonically label output graphs
-u : do not output any graphs, just generate and count them -g : use graph6 output (default) -s : use sparse6 output -n : use nauty format instead of graph6 format for output -y : use the obsolete y-format for output -h : for graph6 or sparse6 format, write a header too
-q : suppress auxiliary output (except from -v)
-x<int> : specify a parameter that determines how evenly the res/mod facility splits the graphs into subsets. High values mean more even splitting at slight cost to the total time. The default is 20*mod, and the the legal minimum is 3*mod. More information is given under "res/mod" above. -X<lev> : move the initial splitting level higher by <lev>, in order to force more even splitting at the cost of speed. Default is -X0. More information is given under "res/mod" above.
Output formats.
The output format is determined by the mutually exclusive switches -u, -n, -y, -g and -s. The default is -g.
-u suppresses output of graphs completely.
-s and -g specify sparse6 and graph6 format, defined elsewhere. In this case a header is also written if -h is present.
If -y is present, graphs will be written in y-format. y-format is obsolete and only provided for backwards compatibility.
Each graph occupies one line with a terminating newline. Except for the newline, each byte has the format 01xxxxxx, where each "x" represents one bit of data. First byte: xxxxxx is the number of vertices n Other ceiling(n(n-1)/12) bytes: These contain the upper triangle of the adjacency matrix in column major order. That is, the entries appear in the order (0,1),(0,2),(1,2),(0,3),(1,3),(2,3),(0,4),... . The bits are used in left to right order within each byte. Any unused bits on the end are set to zero.
If -n is present, any output graphs are written in nauty format.
For a graph of n vertices, the output consists of one int giving the number of vertices, and n setwords containing the adjacency matrix. Note that this is system dependent (i.e. don't use it). It will not work properly if the output is to stdout and your system distinguishes binary and text files.
OUTPROC feature.
By defining the C preprocessor variable OUTPROC at compile time (for Unix the syntax is -DOUTPROC=procname on the cc command), geng can be made to call a procedure of your manufacture with each output graph instead of writing anything. Your procedure needs to have type void and the argument list (FILE *f, graph *g, int n). f is a stream open for writing, g is the graph in nauty format, and n is the number of vertices. Your procedure can be in a separate file so long as it is linked with geng. The global variables sparse6, graph6, quiet, nooutput, nautyformat, and canonise (all type boolean) can be used to test for the presence of the flags -s, -g, -q, -u, -n, and -l, respectively. If -l is present, the group size and similar details can be found in the global variable nauty_stats.
PRUNE feature.
By defining the C preprocessor variable PRUNE at compile time, geng can be made to call int PRUNE(graph *g,int n,int maxn) for each intermediate (and final) graph, and reject it if the value returned is nonzero. The arguments are:
g = the graph in nauty format (m=1) n = the number of vertices in g maxn = the number of vertices for output (the value you gave on the command line to geng)
geng constructs the graph starting with vertex 0, then adding vertices 1,2,3,... in that order. Each graph in the sequence is an induced subgraph of all later graphs in the sequence.
A call is made for all orders from 1 to maxn. In testing for a uniform property (such as a forbidden subgraph or forbidden induced subgraph) it might save time to notice that a call to PRUNE for n implies that the call for n-1 already passed.
For very fast tests, it might be worthwhile using PREPRUNE as well or instead. It has the same meaning but is applied earlier and more often.
If -c or -C is given, the connectivity test is done before PRUNE but not necessarily before PREPRUNE.
Some parameters are available in global variables: geng_mindeg, geng_maxdeg, geng_mine, geng_maxe, geng_connec; SUMMARY
If the C preprocessor variable SUMMARY is defined at compile time, the procedure SUMMARY(nauty_counter nout, double cpu) is called just before the program exits. The purpose is to allow reporting of statistics collected by PRUNE or OUTPROC. The values nout and cpu are the output count and cpu time reported on the >Z line. Output should be written to stderr.
INSTRUMENT feature.
If the C preprocessor variable INSTRUMENT is defined at compile time, extra code is inserted to collect statistics during execution, and more information is written to stderr at termination.
CALLING FROM A PROGRAM
It is possible to call geng from another program instead of using it as a stand-alone program. The main requirement is to change the name of the main program to be other than "main". This is done by defining the preprocessor variable GENG_MAIN. You might also like to define OUTPROC to be the name of a procedure to receive the graphs. To call the program you need to define an argument list argv[] consistent with the usual one; don't forget that argv[0] is the command name and not the first argument. The value of argc is the number of strings in argv[]; that is, one more than the number of arguments. See the sample program callgeng.c.
You can also call geng from multiple threads at once, see the sample program callgeng2.c.
Here we give some graph counts and approximate execution times on a Linux computer with Intel Core i7-4790 nominally 3.6GHz, compiled with gcc 6.2.0. Times are with the -u option (generate but don't write); add 0.2-0.3 microseconds per graph for output to a file.
General Graphs C3-free Graphs (-t)
1 1 1 1 2 2 2 2 3 4 3 3 4 11 4 7 5 34 5 14 6 156 6 38 7 1044 7 107 8 12346 8 410 9 274668 0.08 sec 9 1897 10 12005168 2.7 sec 10 12172 11 1018997864 207 sec 11 105071 0.09 sec 12 165091172592 9 hr 12 1262180 0.8 sec 13 50502031367952 108 days 13 20797002 11 sec These can be done in about half 14 467871369 220 sec the time by setting the edge limit 15 14232552452 1.7 hr half way then adding complements. 16 581460254001 65 hr 17 31720840164950 145 days
To make all the graphs of order n, without restriction on type, it is fastest to make them up to binomial(n,2)/2 edges and append the complement of those with strictly less than binomial(n,2)/2 edges.
If it is necessary to split the computation into pieces, it is more efficient to use the res/mod feature than to split by numbers of edges.
Author: B. D. McKay, Sep 1991 and many later dates. Copyright B. McKay (1991-2018). All rights reserved. This software is subject to the conditions and waivers detailed in the file nauty.h.
Changes: Nov 18, 1991 : added -d switch fixed operation for n=16 Nov 26, 1991 : added OUTPROC feature Nov 29, 1991 : -c implies mine >= n-1 Jan 8, 1992 : make writeny() not static Jan 10, 1992 : added -n switch Feb 9, 1992 : fixed case of n=1 Feb 16, 1992 : changed mine,maxe,maxdeg testing Feb 19, 1992 : added -b, -t and -u options documented OUTPROC and added external declaration for it. Feb 20, 1992 : added -v option Feb 22, 1992 : added INSTRUMENT compile-time option Feb 23, 1992 : added xbnds() for more effective pruning Feb 24, 1992 : added -l option Feb 25, 1992 : changed writenauty() to use fwrite() Mar 11, 1992 : completely revised many parts, incl new refinement procedure for fast rejection, distance invariant for regular graphs May 19, 1992 : modified userautomproc slightly. xorb[] is no longer idempotent but it doesn't matter. Speed-up of 2-5% achieved. June 5, 1993 : removed ";" after "CPUDEFS" to avoid illegal empty declaration. Nov 24, 1994 : tested for 0 <= res < mod
Apr 13, 1996 : Major overhaul. Renamed "geng". Changed argument syntax. Removed 16-vertex limit. Added -s, -m, -x. Allowed combinations. Replaced code for non-general graphs. Very many small changes. Jul 12, 1996 : Changed semantics of -x and res/mod. Changed >A line and added fflush()/ All switches can be concatenated or not. Aug 16, 1996 : Added -X switch and PRUNE() feature. Fixed case of argument 0-0. Sep 22, 1996 : Improved 1-2% by tweaking refinex(). Jan 21, 1997 : Renamed to geng. Changed -s to -f, and added -sghq. Sep 7, 1997 : Fixed WORDSIZE=16 problems. Sep 22, 1997 : Use "wb" open for nautyformat. Jan 26, 1998 : Added SUMMARY feature. Mar 4, 1998 : Added -C. Mar 12, 1998 : Moved stats to nauty_stats. Jan 1, 2000 : Changed -d to -D and added -d. Feb 24, 2000 : Raised limit to 32 vertices. Mar 3, 2000 : Made some counts into unsigned long. (Includes first arg to SUMMARY.) Mar 12, 2000 : Used bigint for counts that may exceed 2^32. Now all counts from very long runs are ok. Oct 12, 2000 : Changed maxef[32] to 92 after confirmation from Yang Yuansheng. The old value of 93 was valid but 92 is slightly more efficient. Nov 16, 2000 : Used fuction prototypes. Jul 31, 2001 : Added PREPRUNE May 7, 2004 : Complete all function prototypes Nov 24, 2004 : Force -m for very large sizes Add -bf automatically if generating trees Apr 1, 2007 : Write >A in one fputs() to try to reduce mixing of outputs in multi-process pipes. Sep 19, 2007 : Force -m for n > 28 regardless of word size. Nov 29, 2008 : Slightly improved connectivity testing. Mar 3, 2015 : Improve maxdeg tweaking. Jan 18, 2016 : Replace bigint by nauty_counter. Mar 8, 2018 : Can now compile for MAXN up to WORDSIZE. Use setword instead of unsigned for xword. Revised splitting level. Updated sample execution times. Mar 10, 2018 : Fix overflow at impossibly large n, maxdeg. Jan 14, 2019 : Define geng_mindeg, geng_maxdeg, geng_mine, geng_maxe. Jun 1, 2021 : Define geng_connec. Jun 4, 2021 : Improve performance for -c and -C with small edge count. Jun 21, 2021 : K1 is not 2-connected. May 15, 2022 : findmax() now deposits -1 at the end of the extended sequence in case geng is being called as a function. Oct 10, 2022 : Obsolete y-format removed
typedefstruct
{ int ne,dmax; /* values used for xlb,xub calculation */ int xlb,xub; /* saved bounds on extension degree */
xword lo,hi; /* work purposes for orbit calculation */
xword xstart[MAXN+1]; /* index into xset[] for each cardinality */
xword *xset; /* array of all x-sets in card order */
xword *xcard; /* cardinalities of all x-sets */
xword *xinv; /* map from x-set to index in xset */
xword *xorb; /* min orbit representative */
xword *xx; /* (-b, -t, -s, -m) candidate x-sets */ /* note: can be the same as xcard */
xword xlim; /* number of x-sets in xx[] */
} leveldata;
static TLS_ATTR leveldata data[MAXN]; /* data[n] is data for n -> n+1 */ static TLS_ATTR nauty_counter ecount[1+MAXN*(MAXN-1)/2]; /* counts by number of edges */ static TLS_ATTR nauty_counter nodes[MAXN]; /* nodes at each level */
/* The numbers below are actual maximum edge counts. geng works correctly with any upper bounds. To extend known upper bounds upwards: (n-1, E) -> (n, E + floor(2*E/(n-2))), which is done by the procedure findmaxe().
*/
static TLS_ATTR int maxeb[65] = /* max edges for -b */
{0,0,1,2,4, -1}; static TLS_ATTR int maxet[65] = /* max edges for -t */
{0,0,1,2,4, -1}; static TLS_ATTR int maxef[65] = /* max edges for -f */
{0,0,1,3,4, 6,7,9,11,13,
16,18,21,24,27, 30,33,36,39,42,
46,50,52,56,59, 63,67,71,76,80,
85,90,92,96,102, 106,110,113,117,122,
127, -1}; static TLS_ATTR int maxeft[65] = /* max edges for -ft */
{0,0,1,2,3, 5,6,8,10,12,
15,16,18,21,23, 26,28,31,34,38,
41,44,47,50,54, 57,61,65,68,72,
76,80,85,87,90, 95,99,104,109,114,
120,124,129,134,139, 145,150,156,162,168,
175,176,178, -1}; static TLS_ATTR int maxebf[65] = /* max edges for -bf */
{0,0,1,2,3, 4,6,7,9,10,
12,14,16,18,21, 22,24,26,29,31,
34,36,39,42,45, 48,52,53,56,58,
61,64,67,70,74, 77,81,84,88,92,
96,100,105,106,108, 110,115,118,122,126,
130,134,138,142,147, 151,156,160,165,170,
175,180,186,187, -1};
void
writenauty(FILE *f, graph *g, int n) /* write graph g (n vertices) to file f in nauty format.
Each graph is preceded by the number of vertices. */
{ int nn;
nn = n;
if (fwrite((char *)&nn,sizeof(int),(size_t)1,f) != 1 ||
fwrite((char*)g,sizeof(graph),(size_t)n,f) != n)
{
fprintf(stderr,">E writenauty : error on writing file\n"); exit(2);
}
}
static boolean
isconnected(graph *g, int n) /* test if g is connected */
{
setword seen,expanded,toexpand,allbits; int i;
allbits = ALLMASK(n);
expanded = bit[n-1];
seen = expanded | g[n-1];
while (seen != allbits && (toexpand = (seen & ~expanded))) /* not == */
{
i = FIRSTBITNZ(toexpand);
expanded |= bit[i];
seen |= g[i];
}
return seen == allbits;
}
static boolean
connpreprune(graph *g, int n, int maxn) /* This function speeds up the generation of connected graphs
with not many edges. */
{
setword notvisited,queue; int ne,nc,i;
if (n == maxn || maxe - maxn >= 5) return 0;
ne = 0; for (i = 0; i < n; ++i) ne += POPCOUNT(g[i]);
ne /= 2;
static boolean
isbiconnected(graph *g, int n) /* test if g is biconnected */
{ int sp,v,w;
setword sw;
setword visited; int numvis,num[MAXN],lp[MAXN],stack[MAXN];
static boolean
distinvar(graph *g, int *invar, int n) /* make distance invariant
return FALSE if n-1 not maximal else return TRUE */
{ int w;
setword workset,frontier;
setword sofar; int inv,d,v;
for (v = n-1; v >= 0; --v)
{
inv = 0;
sofar = frontier = bit[v]; for (d = 1; frontier != 0; ++d)
{
workset = 0;
inv += POPCOUNT(frontier) ^ (0x57 + d); while (frontier)
{
w = FIRSTBITNZ(frontier);
frontier ^= bit[w];
workset |= g[w];
}
frontier = workset & ~sofar;
sofar |= frontier;
}
invar[v] = inv; if (v < n-1 && inv > invar[n-1]) returnFALSE;
} returnTRUE;
}
staticvoid
makebgraph(graph *g, xword *h, int n) /* make x-format graph of different colour graph */
{
setword seen1,seen2,expanded,w;
setword restv;
xword xseen1,xseen2; int i;
restv = 0; for (i = 0; i < n; ++i) restv |= bit[i];
seen1 = seen2 = 0;
expanded = 0;
while (TRUE)
{ if ((w = ((seen1 | seen2) & ~expanded)) == 0)
{
xseen1 = 0;
w = seen1; while (w)
{
i = FIRSTBITNZ(w);
w ^= bit[i];
xseen1 |= XBIT(i);
}
xseen2 = 0;
w = seen2; while (w)
{
i = FIRSTBITNZ(w);
w ^= bit[i];
xseen2 |= XBIT(i);
}
w = seen1; while (w)
{
i = FIRSTBITNZ(w);
w ^= bit[i];
h[i] = xseen2;
}
w = seen2; while (w)
{
i = FIRSTBITNZ(w);
w ^= bit[i];
h[i] = xseen1;
}
restv &= ~(seen1 | seen2); if (restv == 0) return;
i = FIRSTBITNZ(restv);
seen1 = bit[i];
seen2 = 0;
} else
i = FIRSTBITNZ(w);
staticvoid
makeb6graph(graph *g, xword *h, int n) /* make x-format bipartite girth 6 graph */
{
setword w,x;
xword hi; int i,j;
makebgraph(g,h,n);
for (i = 0; i < n; ++i)
{
w = g[i];
x = 0; while (w)
{
j = FIRSTBITNZ(w);
w ^= bit[j];
x |= g[j];
}
x &= ~bit[i];
hi = h[i]; while (x)
{
j = FIRSTBITNZ(x);
x ^= bit[j];
hi |= XBIT(j);
}
h[i] = hi;
}
}
staticvoid
makesgraph(graph *g, xword *h, int n) /* make x-format square graph */
{
setword w,x;
xword hi; int i,j;
for (i = 0; i < n; ++i)
{
w = g[i];
x = 0; while (w)
{
j = FIRSTBITNZ(w);
w ^= bit[j];
x |= g[j];
}
x &= ~bit[i];
hi = 0; while (x)
{
j = FIRSTBITNZ(x);
x ^= bit[j];
hi |= XBIT(j);
}
h[i] = hi;
}
}
staticvoid
makeg5graph(graph *g, xword *h, int n) /* make x-format girth-5 graph */
{
setword w,x;
xword hi; int i,j;
for (i = 0; i < n; ++i)
{
w = g[i];
x = g[i]; while (w)
{
j = FIRSTBITNZ(w);
w ^= bit[j];
x |= g[j];
}
x &= ~bit[i];
hi = 0; while (x)
{
j = FIRSTBITNZ(x);
x ^= bit[j];
hi |= XBIT(j);
}
h[i] = hi;
}
}
staticvoid
makeleveldata(boolean restricted) /* make the level data for each level */
{ long h; int n,nn;
xword ncj;
leveldata *d;
xword *xcard,*xinv;
xword *xset,xw,nxsets;
xword cw;
xword i,ilast,j;
size_t tttn;
for (n = 1; n < maxn; ++n)
{
nn = maxdeg <= n ? maxdeg : n;
ncj = nxsets = 1; for (j = 1; j <= nn; ++j)
{
ncj = arith(ncj,n-j+1,j);
nxsets += ncj;
}
staticvoid
userautomproc(int count, int *p, int *orbits, int numorbits, int stabvertex, int n) /* form orbits on powerset of VG
called by nauty; operates on data[n] */
{
xword i,j1,j2,moved,pi,pxi;
xword lo,hi;
xword *xorb,*xinv,*xset,w;
xorb = data[n].xorb;
xset = data[n].xset;
xinv = data[n].xinv;
lo = data[n].lo;
hi = data[n].hi;
if (count == 1) /* first automorphism */ for (i = lo; i < hi; ++i) xorb[i] = i;
moved = 0; for (i = 0; i < n; ++i) if (p[i] != i) moved |= XBIT(i);
for (i = lo; i < hi; ++i)
{ if ((w = xset[i] & moved) == 0) continue;
pxi = xset[i] & ~moved; while (w)
{
j1 = XNEXTBIT(w);
w ^= XBIT(j1);
pxi |= XBIT(p[j1]);
}
pi = xinv[pxi];
j1 = xorb[i]; while (xorb[j1] != j1) j1 = xorb[j1];
j2 = xorb[pi]; while (xorb[j2] != j2) j2 = xorb[j2];
staticvoid
userautomprocb(int count, int *p, int *orbits, int numorbits, int stabvertex, int n) /* form orbits on powerset of VG
called by nauty; operates on data[n] */
{
xword j1,j2,moved,pi,pxi,lo,hi,x;
xword i,*xorb,*xx,w,xlim,xlb;
xorb = data[n].xorb;
xx = data[n].xx;
xlim = data[n].xlim;
if (count == 1) /* first automorphism */
{
j1 = 0;
xlb = data[n].xlb;
for (i = 0; i < xlim; ++i)
{
x = xx[i]; if (XPOPCOUNT(x) >= xlb)
{
xx[j1] = x;
xorb[j1] = j1;
++j1;
}
}
data[n].xlim = xlim = j1;
}
moved = 0; for (i = 0; i < n; ++i) if (p[i] != i) moved |= XBIT(i);
for (i = 0; i < xlim; ++i)
{ if ((w = xx[i] & moved) == 0) continue;
pxi = xx[i] & ~moved; while (w)
{
j1 = XNEXTBIT(w);
w ^= XBIT(j1);
pxi |= XBIT(p[j1]);
} /* pi = position of pxi */
lo = 0;
hi = xlim - 1;
for (;;)
{
pi = (lo + hi) >> 1; if (xx[pi] == pxi) break; elseif (xx[pi] < pxi) lo = pi + 1; else hi = pi - 1;
}
j1 = xorb[i]; while (xorb[j1] != j1) j1 = xorb[j1];
j2 = xorb[pi]; while (xorb[j2] != j2) j2 = xorb[j2];
/***************************************************************************** * * * refinex(g,lab,ptn,level,numcells,count,active,goodret,code,m,n) is a * * custom version of refine() which can exit quickly if required. * * * * Only use at level==0. * * goodret : whether to do an early return for code 1 * * code := -1 for n-1 not max, 0 for maybe, 1 for definite * * *
*****************************************************************************/
staticvoid
refinex(graph *g, int *lab, int *ptn, int level, int *numcells, int *count, set *active, boolean goodret, int *code, int m, int n)
{ int i,c1,c2,labc1;
setword x,lact; int split1,split2,cell1,cell2; int cnt,bmin,bmax;
set *gptr;
setword workset; int workperm[MAXN]; int bucket[MAXN+2];
if (n == 1)
{
*code = 1; return;
}
*code = 0;
lact = *active;
while (*numcells < n && lact)
{
TAKEBIT(split1,lact);
for (split2 = split1; ptn[split2] > 0; ++split2) {} if (split1 == split2) /* trivial splitting cell */
{
gptr = GRAPHROW(g,lab[split1],1); for (cell1 = 0; cell1 < n; cell1 = cell2 + 1)
{ for (cell2 = cell1; ptn[cell2] > 0; ++cell2) {} if (cell1 == cell2) continue;
static boolean
hasclaw(graph *g, int n, int maxn) /* Return TRUE if there is a claw (induced K(1,3)) involving the last vertex */
{ int i,j,k;
setword x,y;
x = g[n-1]; while (x)
{
TAKEBIT(j,x);
y = x & ~g[j]; while (y)
{
TAKEBIT(k,y); if (y & ~g[k]) returnTRUE;
}
}
x = g[n-1]; while (x)
{
TAKEBIT(i,x);
y = g[i] & ~(bit[n-1]|g[n-1]); while (y)
{
TAKEBIT(k,y); if (y & ~g[k]) returnTRUE;
}
}
returnFALSE;
}
static boolean
hasinducedpath(graph *g, int start, setword body, setword last) /* return TRUE if there is an induced path in g starting at start, extravertices within body and ending in last.
* {start}, body and last should be disjoint. */
{
setword gs,w; int i;
gs = g[start]; if ((gs & last)) returnTRUE;
w = gs & body; while (w)
{
TAKEBIT(i,w); if (hasinducedpath(g,i,body&~gs,last&~bit[i]&~gs)) returnTRUE;
}
returnFALSE;
}
static boolean
notchordal(graph *g, int n, int maxn) /* g is a graph of order n. Return TRUE if there is a chordless cycle of length at least 4 that includes
the last vertex. */
{
setword all,gn,w,gs; int v,s;
all = ALLMASK(n);
gn = g[n-1];
while (gn)
{
TAKEBIT(v,gn);
gs = g[v] & ~(bit[n-1]|g[n-1]); while (gs)
{
TAKEBIT(s,gs); if (hasinducedpath(g,s,all&~(g[n-1]|g[v]),gn&~g[v])) returnTRUE;
}
}
returnFALSE;
}
static boolean
notsplit(graph *g, int n, int maxn) /* g is a graph of order n. Return TRUE if either g or its complement has a chordless cycle of length at least 4 that
includes the last vertex. */
{
graph gc[MAXN];
setword w; int i;
if (notchordal(g,n,maxn)) returnTRUE;
w = ALLMASK(n); for (i = 0; i < n; ++i) gc[i] = g[i] ^ w ^ bit[i]; return notchordal(gc,n,maxn);
}
static boolean
hasinducedoddpath(graph *g, int start, setword body, setword last, boolean parity) /* return TRUE if there is an induced path of odd length >= 3 in g starting at start, extravertices within body and ending in last.
{start}, body and last should be disjoint. */
{
setword gs,w; int i;
gs = g[start]; if ((gs & last) && parity) returnTRUE;
w = gs & body; while (w)
{
TAKEBIT(i,w); if (hasinducedoddpath(g,i,body&~gs,last&~bit[i]&~gs,!parity)) returnTRUE;
}
returnFALSE;
}
static boolean
oddchordless(graph *g, int n, int maxn) /* g is a graph of order n. Return TRUE if there is a chordless cycle of odd length at least 5 that includes
the last vertex. */
{
setword all,gn,w,gs; int v,s;
all = ALLMASK(n);
gn = g[n-1];
while (gn)
{
TAKEBIT(v,gn);
gs = g[v] & ~(bit[n-1]|g[n-1]); while (gs)
{
TAKEBIT(s,gs); if (hasinducedoddpath(g,s,all&~(g[n-1]|g[v]),gn&~g[v],FALSE)) returnTRUE;
}
}
returnFALSE;
}
static boolean
notperfect(graph *g, int n, int maxn) /* g is a graph of order n. Return TRUE if either g or its complement has a chordless cycle of odd length at least 5 that
includes the last vertex. I.e., if it is not perfect. */
{
graph gc[MAXN];
setword w; int i;
if (oddchordless(g,n,maxn)) returnTRUE;
w = ALLMASK(n); for (i = 0; i < n; ++i) gc[i] = g[i] ^ w ^ bit[i]; return oddchordless(gc,n,maxn);
}
static boolean
accept1(graph *g, int n, xword x, graph *gx, int *deg, boolean *rigid) /* decide if n in theta(g+x) - version for n+1 < maxn */
{ int i; int lab[MAXN],ptn[MAXN],orbits[MAXN]; int count[MAXN];
graph h[MAXN];
xword xw; int nx,numcells,code; int i0,i1,degn;
set active[MAXM];
statsblk stats; static TLS_ATTR DEFAULTOPTIONS_GRAPH(options);
setword workspace[50];
#ifdef INSTRUMENT
++a1calls; #endif
nx = n + 1; for (i = 0; i < n; ++i) gx[i] = g[i];
gx[n] = 0;
deg[n] = degn = XPOPCOUNT(x);
xw = x; while (xw)
{
i = XNEXTBIT(xw);
xw ^= XBIT(i);
gx[i] |= bit[n];
gx[n] |= bit[i];
++deg[i];
}
if (k4free && hask4(gx,n+1,maxn)) returnFALSE; if (clawfree && hasclaw(gx,n+1,maxn)) returnFALSE; #ifdef PREPRUNE if (PREPRUNE(gx,n+1,maxn)) returnFALSE; #endif if (connec == 2 && n+2 == maxn && !isconnected(gx,n+1)) returnFALSE; if (((connec ==2 && n+2 < maxn) || (connec == 1 && n+2 <= maxn))
&& connpreprune(gx,n+1,maxn)) returnFALSE;
static boolean
accept1b(graph *g, int n, xword x, graph *gx, int *deg, boolean *rigid, void (*makeh)(graph*,xword*,int)) /* decide if n in theta(g+x) -- version for n+1 < maxn */
{ int i,v;
xword z,hv,bitv,ixx; int lab[MAXN],ptn[MAXN],orbits[MAXN]; int count[MAXN];
graph gc[MAXN];
xword h[MAXN],xw,jxx,kxx,*xx; int nx,numcells,code; int i0,i1,degn,xubx;
set active[MAXM];
statsblk stats; static TLS_ATTR DEFAULTOPTIONS_GRAPH(options);
setword workspace[50];
#ifdef INSTRUMENT
++a1calls; #endif
nx = n + 1; for (i = 0; i < n; ++i) gx[i] = g[i];
gx[n] = 0;
deg[n] = degn = XPOPCOUNT(x);
xw = x; while (xw)
{
i = XNEXTBIT(xw);
xw ^= XBIT(i);
gx[i] |= bit[n];
gx[n] |= bit[i];
++deg[i];
}
if (k4free && hask4(gx,n+1,maxn)) returnFALSE; if (clawfree && hasclaw(gx,n+1,maxn)) returnFALSE; #ifdef PREPRUNE if (PREPRUNE(gx,n+1,maxn)) returnFALSE; #endif if (connec == 2 && n+2 == maxn && !isconnected(gx,n+1)) returnFALSE; if (((connec ==2 && n+2 < maxn) || (connec == 1 && n+2 <= maxe))
&& connpreprune(gx,n+1,maxn)) returnFALSE;
static boolean
accept2(graph *g, int n, xword x, graph *gx, int *deg, boolean nuniq) /* decide if n in theta(g+x) -- version for n+1 == maxn */
{ int i; int lab[MAXN],ptn[MAXN],orbits[MAXN]; int degx[MAXN],invar[MAXN];
setword vmax,gv; int qn,qv; int count[MAXN];
xword xw; int nx,numcells,code; int degn,i0,i1,j,j0,j1;
set active[MAXM];
statsblk stats; static TLS_ATTR DEFAULTOPTIONS_GRAPH(options);
setword workspace[50];
boolean cheapacc;
#ifdef INSTRUMENT
++a2calls; if (nuniq) ++a2uniq; #endif
nx = n + 1; for (i = 0; i < n; ++i)
{
gx[i] = g[i];
degx[i] = deg[i];
}
gx[n] = 0;
degx[n] = degn = XPOPCOUNT(x);
xw = x; while (xw)
{
i = XNEXTBIT(xw);
xw ^= XBIT(i);
gx[i] |= bit[n];
gx[n] |= bit[i];
++degx[i];
}
if (k4free && hask4(gx,n+1,maxn)) returnFALSE; if (clawfree && hasclaw(gx,n+1,maxn)) returnFALSE; #ifdef PREPRUNE if (PREPRUNE(gx,n+1,maxn)) returnFALSE; #endif if (connec == 2 && n+2 == maxn && !isconnected(gx,n+1)) returnFALSE; if (((connec ==2 && n+2 < maxn) || (connec == 1 && n+2 <= maxe))
&& connpreprune(gx,n+1,maxn)) returnFALSE;
if (nuniq)
{ #ifdef INSTRUMENT
++a2succs; #endif if (canonise) makecanon(gx,gcan,nx); returnTRUE;
}
i0 = 0;
i1 = n; for (i = 0; i < nx; ++i)
{ if (degx[i] == degn) lab[i1--] = i; else lab[i0++] = i;
ptn[i] = 1;
}
ptn[n] = 0; if (i0 == 0)
{
numcells = 1;
active[0] = bit[0];
staticvoid
xbnds(int n, int ne, int dmax) /* find bounds on extension degree; store answer in data[*].* */
{ int xlb,xub,d,nn,m,xc;
xlb = n == 1 ? 0 : (dmax > (2*ne + n - 2)/(n - 1) ?
dmax : (2*ne + n - 2)/(n - 1));
xub = n < maxdeg ? n : maxdeg;
for (xc = xub; xc >= xlb; --xc)
{
d = xc;
m = ne + d; for (nn = n+1; nn < maxn; ++nn)
{ if (d < (2*m + nn - 2)/(nn - 1)) d = (2*m + nn - 2)/(nn - 1);
m += d;
} if (d > maxdeg || m > maxe) xub = xc - 1; elsebreak;
}
if (ne + xlb < mine) for (xc = xlb; xc <= xub; ++xc)
{
m = ne + xc; for (nn = n + 1; nn < maxn; ++nn)
m += maxdeg < nn ? maxdeg : nn; if (m < mine) xlb = xc + 1; elsebreak;
}
staticvoid
spaextend(graph *g, int n, int *deg, int ne, boolean rigid, int xlb, int xub, void (*makeh)(graph*,xword*,int)) /* extend from n to n+1 -- version for restricted graphs */
{
xword x,d,dlow;
xword xlim,*xorb; int xc,nx,i,j,dmax,dcrit,xlbx,xubx;
graph gx[MAXN];
xword *xx,ixx; int degx[MAXN];
boolean rigidx;
#ifdef INSTRUMENT
boolean haschild;
haschild = FALSE; if (rigid) ++rigidnodes[n]; #endif
++nodes[n];
nx = n + 1;
dmax = deg[n-1];
dcrit = mindeg - maxn + n;
d = dlow = 0; for (i = 0; i < n; ++i)
{ if (deg[i] == dmax) d |= XBIT(i); if (deg[i] == dcrit) dlow |= XBIT(i);
}
if (xlb == dmax && XPOPCOUNT(d) + dmax > n) ++xlb; if (nx == maxn && xlb < mindeg) xlb = mindeg; if (xlb > xub) return;
if (splitgraph && notsplit(g,n,maxn)) return; if (chordal && notchordal(g,n,maxn)) return; if (perfect && notperfect(g,n,maxn)) return; #ifdef PRUNE if (PRUNE(g,n,maxn)) return; #endif
xorb = data[n].xorb;
xx = data[n].xx;
xlim = data[n].xlim;
staticvoid
genextend(graph *g, int n, int *deg, int ne, boolean rigid, int xlb, int xub) /* extend from n to n+1 -- version for general graphs */
{
xword x,d,dlow;
xword *xset,*xcard,*xorb;
xword i,imin,imax; int nx,xc,j,dmax,dcrit; int xlbx,xubx;
graph gx[MAXN]; int degx[MAXN];
boolean rigidx;
#ifdef INSTRUMENT
boolean haschild;
haschild = FALSE; if (rigid) ++rigidnodes[n]; #endif
++nodes[n];
nx = n + 1;
dmax = deg[n-1];
dcrit = mindeg - maxn + n;
d = dlow = 0; for (i = 0; i < n; ++i)
{ if (deg[i] == dmax) d |= XBIT(i); if (deg[i] == dcrit) dlow |= XBIT(i);
}
if (xlb == dmax && XPOPCOUNT(d) + dmax > n) ++xlb; if (nx == maxn && xlb < mindeg) xlb = mindeg; if (xlb > xub) return;
if (splitgraph && notsplit(g,n,maxn)) return; if (chordal && notchordal(g,n,maxn)) return; if (perfect && notperfect(g,n,maxn)) return; #ifdef PRUNE if (PRUNE(g,n,maxn)) return; #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.