#define HELPTEXT \ " Write graphs in human-readable format.\n\
\n\
-f : assume inputs have same size (only used from a file\n\ and only if -p is given)\n\
-p#, -p#:#, -p#-# : only display one graph or a sequence of\n\
graphs. The first graph is number 1. A second number\n\
which is empty or zero means infinity.\n\ This option won't work for incremental input.\n\
-a : write as adjacency matrix, not as list of adjacencies\n\
-A : same as -a with a space between entries\n\
-l# : specify screen width limit (default 78, 0 means no limit)\n\ This is not currently implemented with -a or -A.\n\
-o# : specify number of first vertex (default is 0).\n\
-d : write output to satisfy dreadnaut \n\
-c : write ascii form with minimal line-breaks\n\
-e : write a list of edges, preceded by the order and the\n\
number of edges\n\
-H : write in HCP operations research format\n\
-M : write in Magma format\n\
-W : write matrix in Maple format\n\
-L : (only with -M or -W) write Laplacian rather than adjacency matrix\n\
-S : (only with -M or -W) write signless Laplacian not adjacency matrix\n\
-b : write in Bliss format\n\
-G : write in GRAPE format\n\
-y : write in dot file format\n\
-Yxxx : extra dotty commands for dot files (arg continues to end of param)\n\
-t : write upper triangle only (affects -a, -A, -d anddefault)\n\
-s : write only the numbers of vertices and edges\n\
-F : write a form-feed after each graph except the last\n\
-q : suppress auxiliary output\n\
\n\
-a, -A, -c, -d, -M, -W, -H and -e are incompatible.\n"
#define MAPLE_MATRIX 1 /* 1 for Matrix(..), 0 for array(..) */
#include"gtools.h" #define LABELORG 0 /* number of first vertex (any integer >= 0) */ #define LINELEN CONSOLWIDTH /* max characters per line (0 = no limit) */
/***************************************************************************** * putsetx(f,set1,curlenp,linelength,m,compress,start) writes the set * * set1 to file f using at most linelength characters per line (excluding * * '\n'). Set elements less than or equal to start are ignored. * * *curlenp is the number of characters on the line so far; it is updated. * * A range j1,j1+1,...,j2 for j2-j1>=2 is written as "j1:j2" if compress * * is nonzero (eg. TRUE); otherwise each element is written separately. * * No final '\n' is written. labelorg is used. * * * * FUNCTIONS CALLED: nextelement(),itos() * * *
*****************************************************************************/
staticvoid
putsetx(FILE *f, set *set1, int *curlenp, int linelength, int m,
boolean compress, int start)
{ int slen,j1,j2; char s[40];
boolean first;
first = TRUE;
j1 = start; while ((j1 = nextelement(set1,m,j1)) >= 0)
{
j2 = j1; if (compress)
{ while (nextelement(set1,m,j2) == j2 + 1)
++j2; if (j2 == j1+1)
j2 = j1;
}
slen = itos(j1 + labelorg,s); if (j2 >= j1 + 2)
{
s[slen] = ':';
slen += 1 + itos(j2 + labelorg,&s[slen+1]);
}
/***************************************************************************** * * * STOLEN FROM naututil.c * * putgraphx(f,g,linelength,m,n) writes a list of the edges of g to f * * using at most linelength characters per line (excluding '\n'). * * If triang, only write the upper triangle. * * labelorg is used. * * *
*****************************************************************************/
staticvoid
putgraphx(FILE *f, graph *g, int linelength, boolean triang, int m, int n)
{ int i,curlen;
set *pg;
for (i = 0, pg = g; i < n; ++i, pg += m)
{
fprintf(f,"%3d : ",i + labelorg);
curlen = 7;
putsetx(f,pg,&curlen,linelength,m,FALSE,triang ? i-1 : -1);
fprintf(f,";\n");
}
}
staticvoid
putedges(FILE *f, graph *g, boolean ptn, int linelength,
boolean digraph, int m, int n) /* Write list of edges, preceded by the numbers of vertices and
edges and optionally by "1" if "ptn" is TRUE. Use labelorg */
{ int i,j,curlen,ne; char s[20];
set *pg;
ne = 0; for (i = 0, pg = g; i < n; ++i, pg += m)
{ for (j = (digraph?-1:i-1); (j = nextelement(pg,m,j)) >= 0;)
++ne;
}
if (ptn) fprintf(f,"%d %d 1\n",n,ne); else fprintf(f,"%d %d\n",n,ne);
staticvoid
putcgraph(FILE *f, graph *g, int linelength, boolean digraph, int m, int n) /* write compressed form, using labelorg */
{ int i,curlen,j0; int semicolons; char s[20];
set *pg;
staticvoid
putve(FILE *f, unsignedlong id, graph *g, boolean digraph, int m, int n) /* Write the numbers of vertices and edges */
{ unsignedlong ne;
setword x,*pg;
ne = 0; for (pg = g + m*(size_t)n; --pg >= g;) if ((x = *pg) != 0) ne += POPCOUNT(x);
fprintf(f,"Graph %lu has %d vertices and %lu edges.\n",id,n,
(digraph?ne:ne/2));
}
for (i = 0, pg = g; i < n; ++i, pg += m)
{
first = TRUE;
fprintf(f," ["); for (j = nextelement(pg,m,-1); j >= 0; j = nextelement(pg,m,j))
{ if (!first) fprintf(f,",");
fprintf(f,"%d",j+1);
first = FALSE;
} if (i < n-1) fprintf(f,"],\n"); else fprintf(f,"]],\n");
}
staticvoid
putbliss(FILE *f, unsignedlong id, boolean qswitch, graph *g, int m, int n) /* Write the graph in Bliss format, according to
* http://www.tcs.hut.fi/Software/bliss/fileformat.shtml */
{ unsignedlong ne;
setword x,*pg; int i,j;
ne = 0; for (pg = g + m*(size_t)n; --pg >= g;) if ((x = *pg) != 0) ne += POPCOUNT(x);
ne /= 2;
staticvoid
putam(FILE *f, graph *g, int linelength, boolean space,
boolean triang, int m, int n) /* write adjacency matrix */
{
set *gi; int i,j;
boolean first;
for (i = 0, gi = (set*)g; i < n - (triang!=0); ++i, gi += m)
{
first = TRUE; for (j = triang ? i+1 : 0; j < n; ++j)
{ if (!first && space) putc(' ',f); else first = FALSE; if (ISELEMENT(gi,j)) putc('1',f); else putc('0',f);
}
putc('\n',f);
}
}
for (i = 0, gi = (set*)g; i < n; ++i, gi += m)
{
fprintf(outfile,"{");
first = TRUE;
j0 = digraph ? -1 : i; for (j = j0; (j = nextelement(gi,m,j)) >= 0; )
{ if (!first) fprintf(outfile,",");
first = FALSE;
fprintf(outfile,"%d",j+1);
}
fprintf(outfile,"}"); if (i != n-1) fprintf(outfile,",\n");
}
fprintf(outfile,"]>;\n");
}
for (i = 0, gi = (set*)g; i < n; ++i, gi += m)
{
fprintf(outfile,"[");
first = TRUE; for (j = 0; j < n; ++j)
{ if (!first) fprintf(outfile,",");
first = FALSE;
fprintf(outfile,"%d",(ISELEMENT(gi,j)?1:0));
}
fprintf(outfile,"]"); if (i != n-1) fprintf(outfile,",\n");
}
fprintf(outfile,"]);\n");
}
staticvoid
putLaplacianMaple(FILE *outfile, graph *g, int linelength, boolean signless, int m, int n, long index)
{ int i,j,d,e;
set *gi;
boolean first;
for (i = 0, gi = (set*)g; i < n; ++i, gi += m)
{
d = 0; for (j = 0; j < m; ++j) d += POPCOUNT(gi[j]);
fprintf(outfile,"[");
first = TRUE; for (j = 0; j < n; ++j)
{ if (!first) fprintf(outfile,",");
first = FALSE; if (j == i) if (ISELEMENT(gi,j)) fprintf(outfile,"%d",d-1); else fprintf(outfile,"%d",d); else if (ISELEMENT(gi,j)) fprintf(outfile,"%d",e); else fprintf(outfile,"%d",0);
}
fprintf(outfile,"]"); if (i != n-1) fprintf(outfile,",\n");
}
fprintf(outfile,"]);\n");
}
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.