#define HELPTEXT \ " Read undirected graphs and orient their edges in all possible ways.\n\
Edges can be oriented in either or both directions (3 possibilities).\n\
Isomorphic directed graphs derived from the same input are suppressed.\n\ If the input graphs are non-isomorphic then the output graphs are also.\n\
\n\
-e# | -e#:# specify a value or range of the total number of arcs\n\
-o orient each edge in only one direction, never both\n\
-a only make acyclic orientations (implies -o)\n\
-f# Use only the subgroup that fixes the first # vertices setwise\n\
\n\
-T use a simple text output format (nv ne edges) instead of digraph6\n\
-G like -T but includes group size as third item (if less than 10^10)\n\
The group size does not include exchange of isolated vertices.\n\
-V only output graphs with nontrivial groups (including exchange of\n\
isolated vertices). The -f option is respected.\n\
-u no output, just count them\n\
-s#/# Make only a fraction of the orientations: The first integer is\n\
the part number (first is 0) and the second is the number of\n\
parts. Splitting is done per input graph independently.\n\
-q suppress auxiliary information\n"
/* DEGPRUNE feature * * If DEGPRUNE is defined it must have a value equal to the name of a * procedure to be supplied by the user and linked to this program. * The prototype must be * int DEGPRUNE(int *indeg, int *outdeg, int v, int n) * Here n is the number of vertices altogether, and v (0..n-1) is the * number of one vertex. At this point in the program, some directed * edges have been inserted, and the indegrees and outdegrees have the * values given in indeg[] and outdeg[]. Moreover, it is known that * no further edges will be added to or from v, so indeg[v] and outdeg[v] * are final. If DEGPRUNE returns a non-zero value, this branch of the * search will be abandoned. * Before any graph is output, DEGPRUNE will have been called for every * vertex, but it cannot be assumed that DEGPRUNE will be called in order * of vertex number.
*/
/* INPUTGRAPH feature * * If INPUTGRAPH is defined, it must expand as the name of a procedure * with prototype like int INPUTGRAPH(graph *g, int m, int n). * This procedure will be called for each input graph before it is * processed. The graph will be skipped if the value 0 is returned.
*/
/* PROCESS feature * * If PROCESS is defined, it must expand as the name of a procedure * with prototype like void PROCESS(FILE *f, graph *g, int n). This * procedure will be called for each output graph before it is output, * with f being the output file (possibly NULL). * It is an error if n > WORDSIZE.
*/
/* SUMMARY feature * * If SUMMARY is defined, it must expand as the name of a procedure * with prototype void SUMMARY(void). It is called at the end before * the normal summary (which can be suppressed with -q). The numbers of * graphs read and digraphs produced are available in the global variables * dg_nin and dg_nout (type nauty_counter).
*/
static boolean
ismax(int *p, int n) /* test if x^p <= x */
{ int i,j,k;
set px[MAXME];
EMPTYSET(px,me);
for (j = 0; j < nix; ++j)
{
i = ix[j];
k = i >> 1; if (i & 1) ADDELEMENT(px,edgeno[p[v1[k]]][p[v0[k]]]); else ADDELEMENT(px,edgeno[p[v0[k]]][p[v1[k]]]);
if (Vswitch && !ntisol && !ntgroup) return MAXNE+1;
++dg_nout;
if (digraph6)
{
EMPTYSET(g,m*n); for (i = -1; (i = nextelement(x,me,i)) >= 0; )
{
k = i >> 1; if (i & 1) ADDELEMENT(g+m*v1[k],v0[k]); else ADDELEMENT(g+m*v0[k],v1[k]);
}
}
#ifdef PROCESS if (!digraph6)
{
EMPTYSET(g,n); for (i = -1; (i = nextelement(x,me,i)) >= 0; )
{
k = i >> 1; if (i & 1) ADDELEMENT(g+m*v1[k],v0[k]); else ADDELEMENT(g+m*v0[k],v1[k]);
}
}
PROCESS(outfile,g,n); #endif
if (digraph6)
writed6(outfile,g,m,n); elseif (outfile)
{
fprintf(outfile,"%d %d",n,ne); if (Gswitch) fprintf(outfile," %lu",newgroupsize);
for (i = -1; (i = nextelement(x,me,i)) >= 0; )
{
k = i >> 1; if (i & 1) fprintf(outfile," %d %d",v1[k],v0[k]); else fprintf(outfile," %d %d",v0[k],v1[k]);
}
fprintf(outfile,"\n");
} return MAXNE+1;
} else return (rejectlevel < splitlevel ? splitlevel : rejectlevel);
}
staticvoid
updatetc(graph *oldtc, graph *newtc, int v, int w, int m, int n) /* Update reflexive transitive closure oldtc with the new
* edge v->w, making newtc. Loops are essential for this to work. */
{ int i,j;
set *gi,*gw;
for (i = 0; i < m*n; ++i) newtc[i] = oldtc[i];
gw = newtc + m*w; for (i = 0, gi = newtc; i < n; ++i, gi += m)
{ if (ISELEMENT(gi,v))
{ for (j = 0; j < m; ++j) gi[j] |= gw[j];
}
}
}
staticvoid
updatetc1(graph *oldtc, graph *newtc, int v, int w, int n) /* Update reflexive transitive closure oldtc with the new * edge v->w, making newtc. Loops are essential for this to work.
Version for m=1. */
{ int i,j;
setword gw;
for (i = 0; i < n; ++i) newtc[i] = oldtc[i];
gw = newtc[w]; for (i = 0; i < n; ++i) if ((newtc[i] & bit[v])) newtc[i] |= gw;
}
staticint
scan_acyclic(int level, int ne, int minarcs, int maxarcs, int sofar,
graph *oldtc, grouprec *group, int m, int n) /* Main recursive scan for acyclic orientations;
* returns the level to return to. */
{ int k,retlev;
graph newtc[MAXNV*MAXMV]; int w0,w1;
staticint
scan_acyclic1(int level, int ne, int minarcs, int maxarcs, int sofar,
graph *oldtc, grouprec *group, int n) /* Main recursive scan for acyclic orientations;
* returns the level to return to. Version for m=1. */
{ int k,retlev;
graph newtc[MAXNV*MAXMV]; int w0,w1;
staticint
scan(int level, int ne, int minarcs, int maxarcs, int sofar,
boolean oriented, grouprec *group, int m, int n) /* Main recursive scan; returns the level to return to. */
{ int k,retlev; #ifdef DEGPRUNE int w0,w1;
staticvoid
direct(graph *g, int nfixed, long minarcs, long maxarcs,
boolean oriented, boolean acyclic, int m, int n) /* Head function for orienting. oriented must be true
if acyclic is true. */
{ static DEFAULTOPTIONS_GRAPH(options);
statsblk stats;
setword workspace[200];
grouprec *group; long ne; int i,j,k,j0,j1,deg; int isol0,isol1; /* isolated vertices before and after nfixed */
set *gi; int lab[MAXNV],ptn[MAXNV],orbits[MAXNV];
set active[(MAXNV+WORDSIZE-1)/WORDSIZE];
graph tc[MAXNV*MAXMV];
nauty_check(WORDSIZE,m,n,NAUTYVERSIONID);
j0 = -1; /* last vertex with degree 0 */
j1 = n; /* first vertex with degree > 0 */
isol0 = isol1 = 0;
ne = 0; for (i = 0, gi = g; i < n; ++i, gi += m)
{
deg = 0; for (j = 0; j < m; ++j) deg += POPCOUNT(gi[j]); if (deg == 0)
{
lab[++j0] = i; if (i < nfixed) ++isol0; else ++isol1;
} else
lab[--j1] = i;
ne += deg;
}
ne /= 2;
ntisol = (isol0 >= 2 || isol1 >= 2);
me = (2*ne + WORDSIZE - 1) / WORDSIZE; if (me == 0) me = 1;
EMPTYSET(x,me);
#ifdef DEGPRUNE for (i = 0; i < n; ++i) indeg[i] = outdeg[i] = 0; #endif #ifndef SPLITTEST if (ne == 0 && minarcs <= 0 && (!Vswitch || ntisol) && splitres == 0)
{ #ifdef DEGPRUNE for (i = 0; i < n; ++i) if (DEGPRUNE(indeg,outdeg,i,n)) break; if (i == n) #endif
trythisone(NULL,0,m,n); // only in case of 0 edges return;
} #endif
if (oriented)
{ if (maxarcs < ne || minarcs > ne) return;
} else
{ if (maxarcs < ne || minarcs > 2*ne) return;
}
if (n > MAXNV || ne > MAXNE)
{
fprintf(stderr,">E directg: MAXNV or MAXNE exceeded\n"); exit(1);
}
for (i = 0; i < n; ++i) ptn[i] = 1;
ptn[n-1] = 0;
EMPTYSET(active,m);
ADDELEMENT(active,0);
for (i = 0; i <= j0; ++i)
{ if (i < n-1) ADDELEMENT(active,i+1);
ptn[i] = 0;
}
for (i = j0+1; i < n; ++i) if (lab[i] < nfixed) break;
if (i != j0+1 && i != n)
{
ptn[i-1] = 0;
ADDELEMENT(active,i);
}
#ifdef DEGPRUNE for (i = 0; i <= j0; ++i) if (DEGPRUNE(indeg,outdeg,lab[i],n)) return; #endif
k = 0; for (i = 0, gi = g; i < n; ++i, gi += m)
{ for (j = i; (j = nextelement(gi,m,j)) >= 0; )
{
v0[k] = i;
v1[k] = j; #ifdef DEGPRUNE
lastlev[i] = lastlev[j] = k; #endif
edgeno[i][j] = 2*k;
edgeno[j][i] = 2*k+1;
++k;
}
}
lastrejok = FALSE;
if (acyclic)
{ for (i = 0; i < m*n; ++i) tc[i] = 0; for (i = 0; i < n; ++i) ADDELEMENT(tc+i*m,i); if (m == 1) scan_acyclic1(0,ne,minarcs,maxarcs,0,tc,group,n); else scan_acyclic(0,ne,minarcs,maxarcs,0,tc,group,m,n);
} else
scan(0,ne,minarcs,maxarcs,0,oriented,group,m,n);
}
t = CPUTIME; while (TRUE)
{ if ((g = readg(infile,NULL,0,&m,&n)) == NULL) break;
++dg_nin; #ifdef PROCESS if (m > 1)
{
fprintf(stderr,">E m=1 is needed if PROCESS is defined\n"); exit(1);
} #endif #ifdef INPUTGRAPH if (!INPUTGRAPH(g,m,n))
{
++dg_skipped;
FREES(g); continue;
} #endif
direct(g,nfixed,minarcs,maxarcs,oswitch,aswitch,m,n); if (!uswitch && ferror(outfile))
gt_abort(">E directg output error\n");
FREES(g);
}
t = CPUTIME - t;
#ifdef SUMMARY
SUMMARY(); #endif
#ifdef SPLITTEST
fprintf(stderr,">S %lu cases at level %d; %.2f sec\n",
splitcases,splitlevel,t); #else if (!qswitch)
{
fprintf(stderr,">Z " COUNTER_FMT " graphs read from %s",
dg_nin,infilename); #ifdef INPUTGRAPH
fprintf(stderr,"; " COUNTER_FMT " skipped",dg_skipped); #endif
fprintf(stderr,"; " COUNTER_FMT ,dg_nout); if (!uswitch)
fprintf(stderr," digraphs written to %s",outfilename); else
fprintf(stderr," digraphs generated");
fprintf(stderr,"; %.2f sec\n",t);
} #endif
#ifdef GROUPTEST
fprintf(stderr,"Group test = %lld\n",totallab); #endif
exit(0);
}
¤ Dauer der Verarbeitung: 0.46 Sekunden
(vorverarbeitet)
¤
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.