Description: format usages and helps Attempt to format usages and helps of the invited programs wrt to the original gtools. Origin: debian Author: Jerome Benoit Last-Update: 2016-03-19 --- a/watercluster2.c +++ b/watercluster2.c @@ -1,54 +1,58 @@ // cc -O4 -o water2 -DWORDSIZE=32 -DMAXN=WORDSIZE nauty.c naugraph.c nautil.c gtools.c schreier.c naurng.c watercluster2.c -/* -Reads graphs in g6 code or multicode (optional) from stdin and directs them - -options: - -ix means: the indegree of every vertex may be at most x. - -oy means: the outdegree of every vertex may be at most y. - - S means: allow that for every pair of vertices x,y at most one of the edges x-->y - and y-->x may be present. By default both of them may be present in the same graph. - - - T means: Output directed graphs in T-code. This is a simple ASCII output format. Every line - contains one graph. First the number of vertices, then the number of - directed edges and then the list of directed edges with the start first - and the end then. E.g.: 3 2 0 1 2 1 means 3 vertices, 2 directed edges: - 0-->1 and 2-->1 - - B means: Output the directed graphs in a binary code. Every item of the code is an unsigned - char. The first unsigned char is the number nv of vertices. The vertices are numbered 1..nv - Then the list of vertices x for which there is a directed edge 1->x follow. This list is - ended by a 0. Then the list of outgoing neighbours of 2 follows -- again ended with a 0, etc. - The code is complete with the 0 ending the list of outgoing neighbours of nv. - - C means: Do really construct all the directed graphs in memory, but don't output them. This is not - a big difference in case of restricted in- and outdegrees, because all that is done extra is that - edges are directed instead of just keeping track of in- and out-degrees. This option is intended only - for testing purposes to test also routines that are normally not used when counting. Things that would - speed up the counting also in some cases of restricted in- and out-degrees -- like multiplying the - possibilities of assigning directions to edges that can be assigned directions independent - of each other (depending on the degrees of the endvertices and overlaps) -- are not included. - In case of not restrictive bounds on the in- and out-degree it not really constructing the graphs - can be considerably faster. In cases of restricted in- and out-degrees the only difference is that - the graph isn't modified... - The fact that in case of no output the graph is not modified is mainly to save time for the one - case of waterclusters, where large numbers were determined. If large numbers (without output) - for other cases shall be determined, one should think about adding the multiplication routines. - - m read multicode - -This program uses different labelling routines -- all based on the ideas of - -G. Brinkmann, Generating water clusters and other directed graphs, -Journal of Mathematical Chemistry 46, 1112--1121 (2009) +#define GTOOL_USAGEHELP_COMPATIBILITY -October 10, 2011: corrected error caused by overflow of 32bit int used as hashvalue. +#define USAGE "watercluster2 [ix] [oy] [S] [T] [B] [C] [m]" -Sep, 2012: PROCESS feature added by BDM. +#define HELPTEXT \ +" Reads graphs in g6 code or multicode (optional) from stdin and directs them\n\ +\n\ + ix : the indegree of every vertex may be at most x.\n\ + The default maximum indegree is unlimited.\n\ +\n\ + oy : the outdegree of every vertex may be at most y.\n\ + The default maximum outdegree is unlimited.\n\ +\n\ + S : allow that for every pair of vertices x,y at most one of the edges x-->y\n\ + and y-->x may be present. By default both of them may be present in the same graph.\n\ +\n\ +\n\ + T : Output directed graphs in T-code. This is a simple ASCII output format. Every line\n\ + contains one graph. First the number of vertices, then the number of\n\ + directed edges and then the list of directed edges with the start first\n\ + and the end then. E.g.: 3 2 0 1 2 1 means 3 vertices, 2 directed edges:\n\ + 0-->1 and 2-->1\n\ +\n\ + B : Output the directed graphs in a binary code. Every item of the code is an unsigned\n\ + char. The first unsigned char is the number nv of vertices. The vertices are numbered 1..nv\n\ + Then the list of vertices x for which there is a directed edge 1->x follow. This list is\n\ + ended by a 0. Then the list of outgoing neighbours of 2 follows -- again ended with a 0, etc.\n\ + The code is complete with the 0 ending the list of outgoing neighbours of nv.\n\ +\n\ + C : Do really construct all the directed graphs in memory, but don't output them. This is not\n\ + a big difference in case of restricted in- and outdegrees, because all that is done extra is that\n\ + edges are directed instead of just keeping track of in- and out-degrees. This option is intended only\n\ + for testing purposes to test also routines that are normally not used when counting. Things that would\n\ + speed up the counting also in some cases of restricted in- and out-degrees -- like multiplying the\n\ + possibilities of assigning directions to edges that can be assigned directions independent\n\ + of each other (depending on the degrees of the endvertices and overlaps) -- are not included.\n\ + In case of not restrictive bounds on the in- and out-degree it not really constructing the graphs\n\ + can be considerably faster. In cases of restricted in- and out-degrees the only difference is that\n\ + the graph isn't modified...\n\ + The fact that in case of no output the graph is not modified is mainly to save time for the one\n\ + case of waterclusters, where large numbers were determined. If large numbers (without output)\n\ + for other cases shall be determined, one should think about adding the multiplication routines.\n\ +\n\ + m : read multicode instead of g6 code\n\ +\n\ +This program uses different labelling routines -- all based on the ideas of\n\ +\n\ +G. Brinkmann, Generating water clusters and other directed graphs,\n\ +Journal of Mathematical Chemistry 46, 1112--1121 (2009)\n" +/* + * October 10, 2011: corrected error caused by overflow of 32bit int used as hashvalue. + * + * Sep, 2012: PROCESS feature added by BDM. */ /* PROCESS feature @@ -67,7 +71,7 @@ * * If SUMMARY is defined, it must expand as the name of a procedure * with prototype void SUMMARY(void). It is called at the end after - * the normal summary. + * the normal summary. */ //#include @@ -500,7 +504,7 @@ return 1; } - +#ifndef GTOOL_USAGEHELP_COMPATIBILITY void usage(char name[]) { @@ -518,6 +522,7 @@ exit(1); } +#endif /**********DECODE_TO_NAUTY****************************************************/ @@ -4013,6 +4018,15 @@ int multicode=0, g6code=1; long long int last=0LL; +#ifdef GTOOL_USAGEHELP_COMPATIBILITY + if (argc > 1 && (strcmp(argv[1],"-help") == 0 + || (strcmp(argv[1],"--help") == 0))) + { + printf("Usage: %s\n\n%s",USAGE,HELPTEXT); + exit(0); + } +#endif + if (sizeof(long long int)<8) { fprintf(stderr,"This may cause problems with the hashing function for large degree -- exit().\n"); @@ -4028,7 +4042,15 @@ else if (argv[i][0]=='B') direct_output=3; else if (argv[i][0]=='S') double_allowed=0; else if (argv[i][0]=='m') { g6code=0; multicode=1; } - else usage(argv[0]); + else { +#ifdef GTOOL_USAGEHELP_COMPATIBILITY + fprintf(stderr,">E Usage: %s\n",USAGE); + fprintf(stderr,"Use watercluster2 -help to see a list of the options.\n"); + exit(1); +#else + usage(argv[0]); +#endif + } } #ifdef PROCESS --- a/genbg.c +++ b/genbg.c @@ -3,8 +3,7 @@ /* TODO: consider colour swaps */ #define USAGE \ -"genbg [-c -ugs -vq -lzF] [-Z#] [-D#] [-A] [-d#|-d#:#] [-D#|-D#:#] n1 n2 \n\ - [mine[:maxe]] [res/mod] [file]" +"genbg [-c -ugs -vq -lzF] [-Z#] [-D#] [-A] [-d#|-d#:#] [-D#|-D#:#] n1 n2 [mine[:maxe]] [res/mod] [file]" #define HELPTEXT \ " Find all bicoloured graphs of a specified class.\n\ --- a/geng.c +++ b/geng.c @@ -6,8 +6,7 @@ /* geng.c version 2.9; B D McKay, Jan 2016. */ #define USAGE \ -"geng [-cCmtfbd#D#] [-uygsnh] [-lvq] \n\ - [-x#X#] n [mine[:maxe]] [res/mod] [file]" +"geng [-cCmtfbd#D#] [-uygsnh] [-lvq] [-x#X#] n [mine[:maxe]] [res/mod] [file]" #define HELPTEXT \ " Generate all graphs of a specified class.\n\ --- a/genrang.c +++ b/genrang.c @@ -2,8 +2,7 @@ /* TODO: Check allocs for no edges */ #define USAGE \ -"genrang [-P#|-P#/#|-e#|-r#|-R#|-d#] [-l#] [-m#] [-t] [-T] [-a] \n" \ -" [-s|-g|-z] [-S#] [-q] n|n1,n2 num [outfile]" +"genrang [-P#|-P#/#|-e#|-r#|-R#|-d#] [-l#] [-m#] [-t] [-T] [-a] [-s|-g|-z] [-S#] [-q] n|n1,n2 num [outfile]" #define HELPTEXT \ " Generate random graphs.\n\ --- a/vcolg.c +++ b/vcolg.c @@ -1,8 +1,7 @@ /* vcolg.c version 1.0; B D McKay, Aug 31, 2013 */ #define USAGE \ -"vcolg [-q] [-u|-T|-G|-A|-B] [-e#|-e#:#] \n" \ -" [-m#] [-f#] [-D#|-r#|-l#] [infile [outfile]]" +"vcolg [-q] [-u|-T|-G|-A|-B] [-e#|-e#:#] [-m#] [-f#] [-D#|-r#|-l#] [infile [outfile]]" #define HELPTEXT \ " Read undirected loop-free graphs and colour their vertices in\n\ --- a/genspecialg.c +++ b/genspecialg.c @@ -1,20 +1,22 @@ /* genspecialg.c version 1.1; B D McKay, Feb 12, 2016 */ -#define USAGE "genspecialg \n\ -[-s|-g|-z|-d] [-q] \ -[-p#|-c#|-e#|-k#|-b#,#|-Q#|-f#|-J#,#|-P#,#|C#,#...|G#,#...|T#,#...] [outfile]" +#define USAGE "genspecialg [-s|-g|-z|-d] [-q] [-p#|-c#|-e#|-k#|-b#,#|-Q#|-f#|-J#,#|-P#,#|C#[,#]|G#[,#]|T#[,#]] [outfile]" #define HELPTEXT \ " Generate one particular graph.\n\ - # : size parameter called n in the descriptions\n\ \n\ +Options:\n\ +General Options:\n\ -s : Write in sparse6 format (default)\n\ -g : Write in graph6 format\n\ -z : Make digraph versions and write in digraph6 format\n\ -d : Write in dreadnaut format (can be used with -z)\n\ -q : Suppress summary\n\ \n\ - If defined, the digraph version is shown in parentheses:\n\ +Special Options:\n\ + If defined, the digraph version is shown in parentheses;\n\ + # size parameter called n in the descriptions.\n\ +\n\ -p# : path (directed path) on n vertices.\n\ -c# : cycle (directed cycle) on n vertices.\n\ -e# : empty graph (digraph with loops only) on n vertices.\n\ @@ -24,9 +26,9 @@ -P#,# : generalized Petersen graph; usual one is -P5,2\n\ -Q# : hypercube on 2^n vertices and degree n.\n\ -J#,# : Johnson graph J(n,k), args are n and k.\n\ - -C#,#... : circulant (di)graph.\n\ - -T#,#... : theta (di)graph Theta(#,#,...), give path lengths.\n\ - -G#,#... : (directed) grid, use negative values for open directions\n" + -C#[,#] : circulant (di)graph.\n\ + -T#[,#] : theta (di)graph Theta(#[,#]), give path lengths.\n\ + -G#[,#] : (directed) grid, use negative values for open directions\n" /* Ideas: multipartite, knesser, full trees */ --- a/cubhamg.c +++ b/cubhamg.c @@ -1,54 +1,53 @@ -/* cubhamg.c : pick those inputs that are nonhamiltonian and - have max degree <= 3. +/* cubhamg.c : pick those inputs that are nonhamiltonian and have max degree <= 3. */ - Usage: -cubhamg [-#] [-v|-V] [-n#-#|-y#-#|-i|-I|-o|-x|-e|-E] [-b|-t] [infile [outfile]] +#define USAGE "cubhamg [-#] [-v|-V] [-n#-#|-y#-#|-i|-I|-o|-x|-e|-E] [-b|-t] [infile [outfile]]" - infile is the name of the input file in graph6/sparse6 format - outfile is the name of the output file in the same format +#define HELPTEXT \ +" Pick those inputs that are nonhamiltonian and have max degree <= 3.\n\ +\n\ + infile is the name of the input file in graph6/sparse6 format (default: stdin)\n\ +\n\ + outfile is the name of the output file in the same format (default: stdout)\n\ +\n\ + The output file will have a header >>graph6<< or >>sparse6<< if the input file does.\n\ +\n\ +Options:\n\ + -# A parameter useful for tuning (default 100)\n\ + -v Report nonhamiltonian graphs and noncubic graphs\n\ + -V .. in addition give a cycle for the hamiltonian ones\n\ + -n#-# If the two numbers are v and i, then the i-th edge\n\ + out of vertex v is required to be not in the cycle.\n\ + It must be that i=1..3 and v=0..n-1.\n\ + -y#-# If the two numbers are v and i, then the i-th edge\n\ + out of vertex v is required to be in the cycle.\n\ + It must be that i=1..3 and v=0..n-1.\n\ + You can use any number of -n/-y switches to force\n\ + edges. Out of range first arguments are ignored.\n\ + If -y and -n give same edge, -y wins.\n\ + -i Test + property: for each edge e, there is a hamiltonian cycle using e.\n\ + -I Test ++ property: for each pair of edges e,e', there is\n\ + a hamiltonian cycle which uses both e and e'.\n\ + -o Test - property: for each edge e, there is a hamiltonian cycle avoiding e.\n\ + -x Test +- property: for each pair of edges e,e', there is\n\ + a hamiltonian cycle which uses e but avoids e'.\n\ + -e Test 3/4 property: for each edge e, at least 3 of the 4\n\ + paths of length 3 passing through e lie on hamiltonian cycles.\n\ + -E Test 3/4+ property: for each edge e failing the 3/4 property,\n\ + all three ways of joining e to the rest of the graph are\n\ + hamiltonian avoiding e.\n\ + -T# Specify a timeout, being a limit on how many search tree\n\ + nodes are made. If the timeout occurs, the graph is\n\ + written to the output as if it is nonhamiltonian.\n\ + -R# Specify the number of repeat attempts for each stage.\n\ + -F Analyze covering paths from 2 or 4 vertices of degree 2.\n\ +\n\ + -b Require biconnectivity\n\ + -t Require triconnectivity (note: quadratic algorithm)\n\ +\n\ +Comments:\n\ + -y, -n, -#, -R and -T are ignored for -i, -I, -x, -o, -e, -E, -F\n" - stdin and stdout are the defaults for infile and outfile - - The output file will have a header >>graph6<< or >>sparse6<< - if and only if the input file does. - - Optional switches: - - -# A parameter useful for tuning (default 100) - -v Report nonhamiltonian graphs and noncubic graphs - -V .. in addition give a cycle for the hamiltonian ones - -n#-# If the two numbers are v and i, then the i-th edge - out of vertex v is required to be not in the cycle. - It must be that i=1..3 and v=0..n-1. - -y#-# If the two numbers are v and i, then the i-th edge - out of vertex v is required to be in the cycle. - It must be that i=1..3 and v=0..n-1. - You can use any number of -n/-y switches to force - edges. Out of range first arguments are ignored. - If -y and -n give same edge, -y wins. - -i Test + property: for each edge e, there is a hamiltonian - cycle using e. - -I Test ++ property: for each pair of edges e,e', there is - a hamiltonian cycle which uses both e and e'. - -o Test - property: for each edge e, there is a hamiltonian - cycle avoiding e. - -x Test +- property: for each pair of edges e,e', there is - a hamiltonian cycle which uses e but avoids e'. - -e Test 3/4 property: for each edge e, at least 3 of the 4 - paths of length 3 passing through e lie on hamiltonian cycles. - -E Test 3/4+ property: for each edge e failing the 3/4 property, - all three ways of joining e to the rest of the graph are - hamiltonian avoiding e. - -T# Specify a timeout, being a limit on how many search tree - nodes are made. If the timeout occurs, the graph is - written to the output as if it is nonhamiltonian. - -R# Specify the number of repeat attempts for each stage. - -F Analyze covering paths from 2 or 4 vertices of degree 2. - - -b Require biconnectivity - -t Require triconnectivity (note: quadratic algorithm) - - -y, -n, -#, -R and -T are ignored for -i, -I, -x, -o, -e, -E, -F +/************************************************************************** B. D. McKay, Nov 1995 + Aug 1996 + Feb 2002 + Jul 2008 + Nov 2015 @@ -1611,6 +1610,8 @@ char *arg; int codetype; + HELP; + infilename = outfilename = NULL; badargs = FALSE; e34plus = e34 = in = out = inin = inout = FALSE; @@ -1729,8 +1730,8 @@ if (badargs) { - fprintf(stderr, - ">E Usage: cubhamg [-#] [-v | -V] [-n#-#] [-y#-#] [infile [outfile]]\n"); + fprintf(stderr, ">E Usage: " USAGE "\n" ); + GETHELP; exit(1); }