#define HELPTEXT \ " Take the converse digraphs of a file of directed graphs.\n\
\n\
The output file has a header if and only if the input file does.\n\
Undirected graphs are passed through without change, while\n\
directed graphs are written in digraph6 format.\n\
\n\
-a Also output the original graph (before the converse)\n\
-c Output only self-converse digraphs\n\
\n\
-q Suppress auxiliary information.\n"
staticvoid
conv(graph *g, int m, int n) /* Replace g by its converse */
{
int i,j;
graph *gi,*gj;
for (i = 0, gi = g; i < n; ++i, gi += m)
for (j = i+1, gj = gi+m; j < n; ++j, gj += m)
if ((ISELEMENT(gi,j)!=0) + (ISELEMENT(gj,i)!=0) == 1)
{
FLIPELEMENT(gi,j);
FLIPELEMENT(gj,i);
}
}
if (badargs)
{
fprintf(stderr,">E Usage: %s\n",USAGE);
GETHELP;
exit(1);
}
if (!quiet)
{
fprintf(stderr,">A converseg");
if (argnum > 0) fprintf(stderr," %s",infilename);
if (argnum > 1) fprintf(stderr," %s",outfilename);
if (also || self)
{
fprintf(stderr,"-");
if (also) fprintf(stderr,"a");
if (self) fprintf(stderr,"c");
}
fprintf(stderr,"\n");
fflush(stderr);
}
if (also && self)
gt_abort(">E converseg: -a and -c are incompatible\n");
if (infilename && infilename[0] == '-') infilename = NULL;
infile = opengraphfile(infilename,&codetype,FALSE,1);
if (!infile) exit(1);
if (!infilename) infilename = "stdin";
if (!outfilename || outfilename[0] == '-')
{
outfilename = "stdout";
outfile = stdout;
} else if ((outfile = fopen(outfilename,"w")) == NULL)
{
fprintf(stderr,"Can't open output file %s\n",outfilename);
gt_abort(NULL);
}
if (codetype&SPARSE6) outcode = SPARSE6; else if (codetype&DIGRAPH6) outcode = DIGRAPH6; else outcode = GRAPH6;
if (codetype&HAS_HEADER)
{
if (outcode == SPARSE6) writeline(outfile,SPARSE6_HEADER); else if (outcode == DIGRAPH6) writeline(outfile,DIGRAPH6_HEADER); else writeline(outfile,GRAPH6_HEADER);
}
gtools_check(WORDSIZE,1,1,NAUTYVERSIONID);
nin = nout = 0;
t = CPUTIME; while (TRUE)
{
if ((g = readgg(infile,NULL,0,&m,&n,&digraph)) == NULL) break;
++nin;
if (!digraph)
{
writelast(outfile);
++nout;
} else if (self)
{
if (isselfconverse(g,m,n))
{
writelast(outfile);
++nout;
}
} else
{
if (also)
{
writed6(outfile,g,m,n);
++nout;
}
conv(g,m,n);
writed6(outfile,g,m,n);
++nout;
}
FREES(g);
}
t = CPUTIME - t;
if (!quiet)
{
if (self)
fprintf(stderr,">Z " COUNTER_FMT " digraphs read from %s; " COUNTER_FMT " self-converse written to %s in %3.2f sec.\n",
nin,infilename,nout,outfilename,t); else
fprintf(stderr,">Z " COUNTER_FMT " graphs converted from %s to %s in %3.2f sec.\n",
nin,infilename,outfilename,t);
}
exit(0);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-09-04)
¤
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.