#define HELPTEXT \ " Find all bicoloured graphs of a specified class.\n\
\n\
n1 : the number of vertices in the first class\n\
n2 : the number of vertices in the second class\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\
file : the name of the output file (default stdout)\n\
-c : only write connected graphs\n\
-z : all the vertices in the second class must have\n\
different neighbourhoods\n\
-F : the vertices in the second class must have at least two\n\
neighbours of degree at least 2\n\
-L : there is no vertex in the first class whose removal leaves\n\
the vertices in the second class unreachable from each other\n\
-Y# : two vertices in the second class must have at least # common nbrs\n\
-Z# : two vertices in the second class must have at most # common nbrs\n\
-A : no vertex in the second class has a neighbourhood which is a\n\
subset of another vertex's neighbourhood in the second class\n\
-D# : specify an upper bound for the maximum degree\n\
Example: -D6. You can also give separate maxima for the\n\
two parts, for example: -D5:6\n\
-d# : specify a lower bound for the minimum degree.\n\
Again, you can specify it separately for the two parts: -d1:2\n\
-g : use graph6 format for output (default)\n\
-s : use sparse6 format for output\n\
-a : use Greechie diagram format for output\n\
-u : donot output any graphs, just generate and count them\n\
-v : display counts by number of edges to stderr\n\
-l : canonically label output graphs (using the 2-part colouring)\n\
\n\
-q : suppress auxiliary output\n\
\n\
See program text for much more information.\n"
/* Output formats.
If -n is absent, any output graphs are written in graph6 format.
If -n is present, any output graphs are written in nauty format.
For a graph of n vertices, the output consists of n+1 long ints (even if a setword is shorter than a long int). The first contains n, and the others contain the adjacency matrix. Long int i of the adjacency matrix (0 <= i <= n-1) is the set of neighbours of vertex i, cast from setword to long int.
PRUNE feature.
By defining the C preprocessor variables PRUNE1 and/or PRUNE2 at compile time, you can filter the output of the program efficiently. The value of the variable is an int function name with parameter list (graph *g, int *deg, int n1, int n2, int maxn2)
The function will be called for each intermediate graph generated by the program, including output graphs. The parameters are: g = the graph in nauty format deg = an array giving the degrees of the vertices n1 = the number of vertices in the first colour class (same as the n1 parameter on the command line) n2 = the number of vertices in the second colour class (this will always be at least 1) maxn2 = the value of n2 on the command line If n2=maxn2, the graph has the output size.
If the function returns a non-zero value, neither this graph nor any of its descendants will be written to the output.
PRUNE1 and PRUNE2 are functionally equivalent, but placed at different points in the program. Essentially, use PRUNE1 for fast tests that eliminate many cases and PRUNE2 for slow tests that eliminate few. If in doubt, try it both ways and choose the fastest. You can use both PRUNE1 and PRUNE2 if you wish, in which case note that the PRUNE1 test has already been passed before PRUNE2 is applied.
Vertices 0..n1-1 are always present. The program works by successively adding one more vertex to the second colour class. Vertex n1+n2-1 is always the last one that has been added, and (except for n2=1) the subgraph formed by deleting n1+n2-1 has previously been passed by the pruning function.
Note that neither PRUNE1 nor PRUNE2 are called with n2=0, even if that is the output level.
If -c is specified, the connectivity test has NOT been performed yet at the time the pruning function is called. However the simplicity test indicated by -z HAS been performed if -z is specified.
OUTPROC feature.
By defining the C preprocessor variable OUTPROC at compile time (for Unix the syntax is -DOUTPROC=procname on the cc command), genbg 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 n1, int n2). f is a stream open for writing, g is the graph in nauty format, and n1,n2 are the numbers of vertices on each side. Your procedure can be in a separate file so long as it is linked with genbg. The global variables nooutput, nautyformat and canonise (all type boolean) can be used to test for the presence of the flags -u, -n and -l, respectively.
For backward compatibility, it is possible to instead define OUTPROC1 to be the name of a procedure with argument list (FILE *f, graph *g, int n).
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 PRUNE1/2 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.
Author: B. D. McKay, Oct 1994. brendan.mckay@anu.edu.au Copyright B. McKay (1994-2017). All rights reserved. This software is subject to the conditions and waivers detailed in the file COPYRIGHT. 1 May 2003 : fixed PRUNE feature 13 Sep 2003 : added Greechie output, all outprocs have n1,n2 9 Oct 2003 : changed -l to respect partition 11 Apr 2007 : make >A line more atomic 29 Aug 2008 : include PLUGIN insertion 29 Nov 2008 : slight improvement of connectivity testing 27 Jul 2011 : fixed error in PRUNE1 found by Stephen Hartke 8 Jan 2012 : add antichains -A suggested by Andrew Juell 23 Jan 2013 : fix splitlevinc initialization 16 Feb 2014 : add a missing call to PRUNE2 20 Jan 2016 : changed bigint to nauty_counter 14 Nov 2017 : added -Y switch 6 Oct 2019 : declare PRUNE1 and PRUNE2
static FILE *outfile; /* file for output graphs */ static boolean connec; /* presence of -c */ static boolean verbose; /* presence of -v */ static boolean simple; /* presence of -z */
boolean nautyformat; /* presence of -n */
boolean nooutput; /* presence of -u */
boolean canonise; /* presence of -l */
boolean graph6; /* presence of -g */
boolean sparse6; /* presence of -s */
boolean greout; /* presence of -a */
boolean quiet; /* presence of -q */
boolean footfree; /* presence of -F */
boolean cutfree; /* presence of -L */
boolean antichain; /* presence of -A */ int class1size; /* same as n1 */ int mincommon; /* -1 or value of -Y */ int maxcommon; /* -1 or value of -Z */ staticint maxdeg1,maxdeg2,n1,maxn2,mine,maxe,nprune,mod,res,curres; staticint mindeg1,mindeg2; static graph gcan[MAXN]; staticint xval[MAXN]; /* x-bit version of second class, xval[0..] */
typedefstruct
{ int ne,dmax; /* values used for xlb,xub calculation */ int xlb,xub; /* saved bounds on extension degree */ int lo,hi; /* work purposes for orbit calculation */ int *xorb; /* min orbit representative */
} leveldata;
#define IFLE1BITS(ww) if (!((ww)&((ww)-1)))
static leveldata data[MAXN]; /* data[n] is data for n -> n+1 */ static nauty_counter ecount[1+MAXN*MAXN/4]; /* counts by number of edges */ staticint xstart[MAXN+1]; /* index into xset[] for each cardinality */ staticint *xset; /* array of all x-sets in card order */ staticint *xcard; /* cardinalities of all x-sets */ staticint *xinv; /* map from x-set to index in xset */
void
writeny(FILE *f, graph *g, int n1, int n2) /* write graph g (n1+n2 vertices) to file f in y format */
{ staticchar ybit[] = {32,16,8,4,2,1}; char s[(MAXN*(MAXN-1)/2 + 5)/6 + 4]; int i,j,k; char y,*sp; int n;
n = n1 + n2;
sp = s;
*(sp++) = 0x40 | n;
y = 0x40;
k = -1; for (j = 1; j < n; ++j) for (i = 0; i < j; ++i)
{ if (++k == 6)
{
*(sp++) = y;
y = 0x40;
k = 0;
} if (g[i] & bit[j]) y |= ybit[k];
} if (n >= 2) *(sp++) = y;
*(sp++) = '\n';
*sp = '\0';
if (fputs(s,f) == EOF || ferror(f))
{
fprintf(stderr,">E writeny : error on writing file\n"); exit(2);
}
}
void
writegre(FILE *f, graph *g, int n1, int n2) /* write graph g (n1+n2 vertices) to file f in Greechie diagram format */
{ staticchar atomname[] = "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ\
abcdefghijklmnopqrstuvwxyz!\"#$%&'()*-/:;<=>?@[\\]^_`{|}~"; char grestr[MAXN*MAXN+MAXN+5]; int i,j,k;
setword gi;
k = 0; for (i = n1; i < n1+n2; ++i)
{ if (i > n1) grestr[k++] = ',';
gi = g[i]; while (gi)
{
TAKEBIT(j,gi);
grestr[k++] = atomname[j];
}
}
grestr[k++] = '.';
grestr[k++] = '\n';
grestr[k] = '\0'; if (fputs(grestr,f) == EOF || ferror(f))
{
fprintf(stderr,">E genbg : error on writing file\n");
gt_abort(NULL);
}
}
staticvoid
fragments(int *x, int nx, int *frag, int *nfrag) /* For each v in union(x[0..nx-1]), find the components of the
hypergraph x - v and add them to frag if there are more than one. */ /* This implementation is shocking. Improve it! */
{ int allx,i,j,v; int vbit,nw,w[MAXN];
boolean done;
allx = 0; for (i = 0; i < nx; ++i) allx |= x[i];
*nfrag = 0;
while (allx)
{
v = XNEXTBIT(allx);
vbit = xbit[v];
allx &= ~vbit;
for (i = 0; i < nx; ++i) w[i] = x[i] & ~vbit;
nw = nx;
done = FALSE; while (!done && nw > 1)
{
done = TRUE; for (i = 0; i < nw-1; ++i) for (j = i+1; j < nw; ) if ((w[i] & w[j]) != 0)
{
w[i] |= w[j];
w[j] = w[nw-1];
--nw;
done = FALSE;
} else
++j;
}
if (nw > 1) for (i = 0; i < nw; ++i)
frag[(*nfrag)++] = w[i];
}
}
static boolean
distinvar(graph *g, int *invar, int n1, int n2) /* make distance invariant/ exit immediately FALSE if n-1 not maximal else exit TRUE
Note: only invar[n1..n1+n2-1] set */
{ int w,n;
setword workset,frontier;
setword sofar; int inv,d,v;
n = n1 + n2; for (v = n-1; v >= n1; --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
userautomproc(int count, int *p, int *orbits, int numorbits, int stabvertex, int n) /* Automorphism procedure called by nauty Form orbits on powerset of VG
Operates on data[n-n1] */
{ int i,j1,j2; int moved,pxi,pi; int w,lo,hi; int *xorb;
xorb = data[n-n1].xorb;
lo = data[n-n1].lo;
hi = data[n-n1].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];
/***************************************************************************** * * * 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; int split1,split2,cell1,cell2; int cnt,bmin,bmax;
set *gptr;
setword workset; int workperm[MAXN]; int bucket[MAXN+2];
static boolean
accept1(graph *g, int n2, int x, graph *gx, int *deg, boolean *rigid) /* decide if n2 in theta(g+x) -- version for n2+1 < maxn2 */
{ int i,n; int lab[MAXN],ptn[MAXN],orbits[MAXN]; int count[MAXN];
graph h[MAXN]; int xw; int nx,numcells,code; int i0,i1,degn;
set active[MAXM];
statsblk stats; static DEFAULTOPTIONS_GRAPH(options);
setword workspace[50];
#ifdef INSTRUMENT
++a1calls; #endif
n = n1 + n2;
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];
} #ifdef PRUNE1 if (PRUNE1(gx,deg,n1,n2+1,maxn2)) returnFALSE; #endif
for (i = 0; i < n1; ++i)
{
lab[i] = i;
ptn[i] = 1;
}
ptn[n1-1] = 0;
i0 = n1;
i1 = n; for (i = n1; i < nx; ++i)
{ if (deg[i] == degn) lab[i1--] = i; else lab[i0++] = i;
ptn[i] = 1;
}
static boolean
accept2(graph *g, int n2, int x, graph *gx, int *deg, boolean nuniq) /* decide if n in theta(g+x) -- version for n+1 == maxn */
{ int i,n; int lab[MAXN],ptn[MAXN],orbits[MAXN]; int degx[MAXN],invar[MAXN];
setword vmax,gv; int qn,qv; int count[MAXN]; int xw; int nx,numcells,code; int degn,i0,i1,j,j0,j1;
set active[MAXM];
statsblk stats; static DEFAULTOPTIONS_GRAPH(options);
setword workspace[50];
#ifdef INSTRUMENT
++a2calls; if (nuniq) ++a2uniq; #endif
n = n1 + n2;
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];
} #ifdef PRUNE1 if (PRUNE1(gx,degx,n1,n2+1,maxn2)) returnFALSE; #endif
if (nuniq)
{ #ifdef INSTRUMENT
++a2succs; #endif #ifdef PRUNE2 if (PRUNE2(gx,degx,n1,n2+1,maxn2)) returnFALSE; #endif if (canonise) makecanon(gx,gcan,n1,n2+1); returnTRUE;
}
for (i = 0; i < n1; ++i)
{
lab[i] = i;
ptn[i] = 1;
}
ptn[n1-1] = 0;
i0 = n1;
i1 = n; for (i = n1; i < nx; ++i)
{ if (degx[i] == degn) lab[i1--] = i; else lab[i0++] = i;
ptn[i] = 1;
}
staticvoid
genextend(graph *g, int n2, int *deg, int ne, boolean rigid, int xlb, int xub) /* extend from n2 to n2+1 */
{ int x,y,d; int *xorb,xc; int nx,i,j,imin,imax,dmax; int xlbx,xubx,n;
graph gx[MAXN]; int degx[MAXN];
boolean rigidx; int dneed,need,nfeet,hideg,deg1,ft[MAXN],nfrag,frag[MAXN];
#ifdef INSTRUMENT
boolean haschild;
haschild = FALSE;
++nodes[n2]; if (rigid) ++rigidnodes[n2]; #endif
n = n1 + n2;
nx = n2 + 1;
dmax = deg[n-1];
d = 0;
dneed = mindeg1 - maxn2 + n2;
need = 0;
hideg = 0;
deg1 = 0; for (i = 0; i < n1; ++i)
{ if (deg[i] == maxdeg1) d |= xbit[i]; if (deg[i] <= dneed) need |= xbit[i]; if (deg[i] >= 2) hideg |= xbit[i]; if (deg[i] == 1) deg1 |= xbit[i];
}
if (xlb < XPOPCOUNT(need)) xlb = XPOPCOUNT(need); if (xlb > xub) return;
int
main(int argc, char *argv[])
{ char *arg;
boolean badargs,gotD,gote,gotf,gotmr,gotY,gotZ,gotd,gotX; long Dval1,Dval2; long dval1,dval2; int i,j,imin,imax,argnum,sw; int splitlevinc;
graph g[MAXN1]; int deg[MAXN1];
nauty_counter nout; double t1,t2; char *outfilename; char msg[201];
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 und die Messung sind noch experimentell.