1/**************************************************************************
2*    This is the header file for Version 2.2 of nauty().                  *
3*    @configure_input@
4**************************************************************************/
5
6#ifndef  _NAUTY_H_    /* only process this file once */
7#define  _NAUTY_H_
8
9/* The parts between the ==== lines are modified by configure when
10creating nauty.h out of nauty-h.in.  If configure is not being used,
11it is necessary to check they are correct.
12====================================================================*/
13
14/* Check whether various headers are available */
15#define HAVE_UNISTD_H  @header_unistd_h@    /* <unistd.h> */
16#define HAVE_SYSTYPES_H  @header_sys_types_h@    /* <sys/types.h> */
17#define HAVE_STDDEF_H  @header_stddef_h@     /* <stddef.h> */
18#define HAVE_STDLIB_H  @header_stdlib_h@    /* <stdlib.h> */
19#define HAVE_STRING_H  @header_string_h@    /* <string.h> */
20#define MALLOC_DEC @malloc_dec@  /* 1 = malloc() is declared in stdlib.h,
21				 2 = in malloc.h, 0 = in neither place */
22#define HAS_MATH_INF @has_math_inf@ /* INFINITY is defined in math.h or
23				some system header likely to be used */
24
25#define SIZEOF_INT @ac_cv_sizeof_int@
26#define SIZEOF_LONG @ac_cv_sizeof_long@
27#define SIZEOF_LONG_LONG @ac_cv_sizeof_long_long@   /* 0 if nonexistent */
28
29#define HAVE_CONST @have_const@    /* compiler properly supports const */
30
31/*==================================================================*/
32
33/* The following line must be uncommented for compiling into Magma. */
34/* #define NAUTY_IN_MAGMA  */
35
36#ifdef NAUTY_IN_MAGMA
37#include "defs.h"
38#include "system.h"
39#include "bs.h"
40#undef BIGNAUTY
41#define BIGNAUTY
42#undef OLDEXTDEFS
43#define OLDEXTDEFS
44#else
45#include <stdio.h>
46#define P_(x) x
47#endif
48
49#if defined(__cray) || defined(__cray__) || defined(cray)
50#define SYS_CRAY        /* Cray UNIX, portable or standard C */
51#endif
52
53#if defined(__unix) || defined(__unix__) || defined(unix)
54#define SYS_UNIX
55#endif
56
57#if !HAVE_CONST
58#define const
59#endif
60
61/*****************************************************************************
62*                                                                            *
63*    AUTHOR: Brendan D. McKay                                                *
64*            Computer Science Department                                     *
65*            Australian National University                                  *
66*            Canberra, ACT 0200, Australia                                   *
67*            phone:  +61 2 6125 3845    fax:  +61 2 6125 0010                *
68*            email:  bdm@cs.anu.edu.au                                       *
69*                                                                            *
70*   Copyright (1984-2004) Brendan McKay.  All rights reserved.  Permission   *
71*   is hereby given for use and/or distribution with the exception of        *
72*   sale for profit or application with nontrivial military significance.    *
73*   You must not remove this copyright notice, and you must document any     *
74*   changes that you make to this program.                                   *
75*   This software is subject to this copyright only, irrespective of         *
76*   any copyright attached to any package of which this is a part.           *
77*                                                                            *
78*   This program is only provided "as is".  No responsibility will be taken  *
79*   by the author, his employer or his pet rabbit* for any misfortune which  *
80*   befalls you because of its use.  I don't think it will delete all your   *
81*   files, burn down your computer room or turn your children against you,   *
82*   but if it does: stiff cheddar.  On the other hand, I very much welcome   *
83*   bug reports, or at least I would if there were any bugs.                 *
84*                                                       * RIP, 1989          *
85*                                                                            *
86*   If you wish to acknowledge use of this program in published articles,    *
87*   please do so by citing the User's Guide:                                 *
88*                                                                            *
89*     B. D. McKay, nauty User's Guide (Version 1.5), Technical Report        *
90*         TR-CS-90-02, Australian National University, Department of         *
91*         Computer Science, 1990.                                            *
92*                                                                            *
93*   CHANGE HISTORY                                                           *
94*       10-Nov-87 : final changes for version 1.2                            *
95*        5-Dec-87 : renamed to version 1.3 (no changes to this file)         *
96*       28-Sep-88 : added PC Turbo C support, making version 1.4             *
97*       23-Mar-89 : changes for version 1.5 :                                *
98*                   - reworked M==1 code                                     *
99*                   - defined NAUTYVERSION string                            *
100*                   - made NAUTYH_READ to allow this file to be read twice   *
101*                   - added optional ANSI function prototypes                *
102*                   - added validity check for WORDSIZE                      *
103*                   - added new fields to optionblk structure                *
104*                   - updated DEFAULTOPTIONS to add invariants fields        *
105*                   - added (set*) cast to definition of GRAPHROW            *
106*                   - added definition of ALLOCS and FREES                   *
107*       25-Mar-89 : - added declaration of new function doref()              *
108*                   - added UNION macro                                      *
109*       29-Mar-89 : - reduced the default MAXN for small machines            *
110*                   - removed OUTOFSPACE (no longer used)                    *
111*                   - added SETDIFF and XOR macros                           *
112*        2-Apr-89 : - extended statsblk structure                            *
113*        4-Apr-89 : - added IS_* macros                                      *
114*                   - added ERRFILE definition                               *
115*                   - replaced statsblk.outofspace by statsblk.errstatus     *
116*        5-Apr-89 : - deleted definition of np2vector (no longer used)       *
117*                   - introduced EMPTYSET macro                              *
118*       12-Apr-89 : - eliminated MARK, UNMARK and ISMARKED (no longer used)  *
119*       18-Apr-89 : - added MTOOBIG and CANONGNIL                            *
120*       12-May-89 : - made ISELEM1 and ISELEMENT return 0 or 1               *
121*        2-Mar-90 : - added EXTPROC macro and used it                        *
122*       12-Mar-90 : - added SYS_CRAY, with help from N. Sloane and A. Grosky *
123*                   - added dummy groupopts field to optionblk               *
124*                   - select some ANSI things if __STDC__ exists             *
125*       20-Mar-90 : - changed default MAXN for Macintosh versions            *
126*                   - created SYS_MACTHINK for Macintosh THINK compiler      *
127*       27-Mar-90 : - split SYS_MSDOS into SYS_PCMS4 and SYS_PCMS5           *
128*       13-Oct-90 : changes for version 1.6:                                 *
129*                   - fix definition of setword for WORDSIZE==64             *
130*       14-Oct-90 : - added SYS_APOLLO version to avoid compiler bug         *
131*       15-Oct-90 : - improve detection of ANSI conformance                  *
132*       17-Oct-90 : - changed temp name in EMPTYSET to avoid A/UX bug        *
133*       16-Apr-91 : changes for version 1.7:                                 *
134*                   - made version SYS_PCTURBO use free(), not cfree()       *
135*        2-Sep-91 : - noted that SYS_PCMS5 also works for Quick C            *
136*                   - moved MULTIPLY to here from nauty.c                    *
137*       12-Jun-92 : - changed the top part of this comment                   *
138*       27-Aug-92 : - added version SYS_IBMC, thanks to Ivo Duentsch         *
139*        5-Jun-93 : - renamed to version 1.7+, only change in naututil.h     *
140*       29-Jul-93 : changes for version 1.8:                                 *
141*                   - fixed error in default 64-bit version of FIRSTBIT      *
142*                     (not used in any version before ALPHA)                 *
143*                   - installed ALPHA version (thanks to Gordon Royle)       *
144*                   - defined ALLOCS,FREES for SYS_IBMC                      *
145*        3-Sep-93 : - make calloc void* in ALPHA version                     *
146*       17-Sep-93 : - renamed to version 1.9,                                *
147*                        changed only dreadnaut.c and nautinv.c              *
148*       24-Feb-94 : changes for version 1.10:                                *
149*                   - added version SYS_AMIGAAZT, thanks to Carsten Saager   *
150*                     (making 1.9+)                                          *
151*       19-Apr-95 : - added prototype wrapper for C++,                       *
152*                     thanks to Daniel Huson                                 *
153*        5-Mar-96 : - added SYS_ALPHA32 version (32-bit setwords on Alpha)   *
154*       13-Jul-96 : changes for version 2.0:                                 *
155*                   - added dynamic allocation                               *
156*                   - ERRFILE must be defined                                *
157*                   - added FLIPELEM1 and FLIPELEMENT macros                 *
158*       13-Aug-96 : - added SWCHUNK? macros                                  *
159*                   - added TAKEBIT macro                                    *
160*       28-Nov-96 : - include sys/types.h if not ANSI (tentative!)           *
161*       24-Jan-97 : - and stdlib.h if ANSI                                   *
162*                   - removed use of cfree() from UNIX variants              *
163*       25-Jan-97 : - changed options.getcanon from boolean to int           *
164*                     Backwards compatibility is ok, as boolean and int      *
165*                     are the same.  Now getcanon=2 means to get the label   *
166*                     and not care about the group.  Sometimes faster.       *
167*        6-Feb-97 : - Put in #undef for FALSE and TRUE to cope with          *
168*                     compilers that illegally predefine them.               *
169*                   - declared nauty_null and nautil_null                    *
170*        2-Jul-98 : - declared ALLBITS                                       *
171*       21-Oct-98 : - allow WORDSIZE==64 using unsigned long long            *
172*                   - added BIGNAUTY option for really big graphs            *
173*       11-Dec-99 : - made bit, leftbit and bytecount static in each file    *
174*        9-Jan-00 : - declared nauty_check() and nautil_check()              *
175*       12-Feb-00 : - Used #error for compile-time checks                    *
176*                   - Added DYNREALLOC                                       *
177*        4-Mar-00 : - declared ALLMASK(n)                                    *
178*       27-May-00 : - declared CONDYNFREE                                    *
179*       28-May-00 : - declared nautil_freedyn()                              *
180*       16-Aug-00 : - added OLDNAUTY and changed canonical labelling         *
181*       16-Nov-00 : - function prototypes are now default and unavoidable    *
182*                   - removed UPROC, now assume all compilers know void      *
183*                   - removed nvector, now just int (as it always was)       *
184*                   - added extra parameter to targetcell()                  *
185*                   - removed old versions which were only to skip around    *
186*                     bugs that should have been long fixed:                 *
187*                     SYS_APOLLO and SYS_VAXBSD.                             *
188*                   - DEFAULTOPIONS now specifies no output                  *
189*                   - Removed obsolete SYS_MACLSC version                    *
190*       21-Apr-01 : - Added code to satisfy compilation into Magma.  This    *
191*                       is activated by defining NAUTY_IN_MAGMA above.       *
192*                   - The *_null routines no longer exist                    *
193*                   - Default maxinvarlevel is now 1.  (This has no effect   *
194*                        unless an invariant is specified.)                  *
195*                   - Now labelorg has a concrete declaration in nautil.c    *
196*                        and EXTDEFS is not needed                           *
197*        5-May-01 : - NILFUNCTION, NILSET, NILGRAPH now obsolete.  Use NULL. *
198*       11-Sep-01 : - setword is unsigned int in the event that UINT_MAX     *
199*                     is defined and indicates it is big enough              *
200*       17-Oct-01 : - major rewrite for 2.1.  SYS_* variables gone!          *
201*                     Some modernity assumed, eg size_t                      *
202*        8-Aug-02 : - removed MAKEEMPTY  (use EMPTYSET instead)              *
203*                   - deleted OLDNAUTY everywhere                            *
204*       27-Aug-02 : - converted to use autoconf.  Now the original of this   *
205*                     file is nauty-h.in. Run configure to make nauty.h.     *
206*       20-Dec-02 : - increased INFINITY                                     *
207*                     some reorganization to please Magma                    *
208*                   - declared nauty_freedyn()                               *
209*       17-Nov-03 : - renamed INFINITY to NAUTY_INFINITY                     *
210*       29-May-04 : - added definition of SETWORD_FORMAT                     *
211*       14-Sep-04 : - extended prototypes even to recursive functions        *
212*       16-Oct-04 : - added DEFAULTOPTIONS_GRAPH                             *
213*       24-Oct-04 : Starting 2.3                                             *
214*                   - remove register declarations as modern compilers       *
215*                     tend to find them a nuisance                           *
216*                   - Don't define the obsolete symbol INFINITY if it is     *
217*                     defined already                                        *
218*                                                                            *
219*****************************************************************************/
220
221/*****************************************************************************
222*                                                                            *
223*   16-bit, 32-bit and 64-bit versions can be selected by defining WORDSIZE. *
224*   The largest graph that can be handled has MAXN vertices.                 *
225*   Both WORDSIZE and MAXN can be defined on the command line.               *
226*   WORDSIZE must be 16, 32 or 64; MAXN must be <= NAUTY_INFINITY - 2;       *
227*                                                                            *
228*   With a very slight loss of efficiency (depending on platform), nauty     *
229*   can be compiled to dynamically allocate arrays.  Predefine MAXN=0 to     *
230*   achieve this effect, which is default behaviour from version 2.0.        *
231*   In that case, graphs of size up to NAUTY_INFINITY-2 can be handled       *
232*   if the the memory is available.                                          *
233*                                                                            *
234*   If only very small graphs need to be processed, use MAXN<=WORDSIZE       *
235*   since this causes substantial code optimizations.                        *
236*                                                                            *
237*   Conventions and Assumptions:                                             *
238*                                                                            *
239*    A 'setword' is the chunk of memory that is occupied by one part of      *
240*    a set.  This is assumed to be >= WORDSIZE bits in size.                 *
241*                                                                            *
242*    The rightmost (loworder) WORDSIZE bits of setwords are numbered         *
243*    0..WORDSIZE-1, left to right.  It is necessary that the 2^WORDSIZE      *
244*    setwords with the other bits zero are totally ordered under <,=,>.      *
245*    This needs care on a 1's-complement machine.                            *
246*                                                                            *
247*    The int variables m and n have consistent meanings throughout.          *
248*    Graphs have n vertices always, and sets have m setwords always.         *
249*                                                                            *
250*    A 'set' consists of m contiguous setwords, whose bits are numbered      *
251*    0,1,2,... from left (high-order) to right (low-order), using only       *
252*    the rightmost WORDSIZE bits of each setword.  It is used to             *
253*    represent a subset of {0,1,...,n-1} in the usual way - bit number x     *
254*    is 1 iff x is in the subset.  Bits numbered n or greater, and           *
255*    unnumbered bits, are assumed permanently zero.                          *
256*                                                                            *
257*    A 'graph' consists of n contiguous sets.  The i-th set represents       *
258*    the vertices adjacent to vertex i, for i = 0,1,...,n-1.                 *
259*                                                                            *
260*    A 'permutation' is an array of n short ints (ints in the case that      *
261*    BIGNAUTY is defined) , repesenting a permutation of the set             *
262*    {0,1,...,n-1}.  The value of the i-th entry is the number to which      *
263*    i is mapped.                                                            *
264*                                                                            *
265*    If g is a graph and p is a permutation, then g^p is the graph in        *
266*    which vertex i is adjacent to vertex j iff vertex p[i] is adjacent      *
267*    to vertex p[j] in g.                                                    *
268*                                                                            *
269*    A partition nest is represented by a pair (lab,ptn), where lab and ptn  *
270*    are int arrays.  The "partition at level x" is the partition whose      *
271*    cells are {lab[i],lab[i+1],...,lab[j]}, where [i,j] is a maximal        *
272*    subinterval of [0,n-1] such that ptn[k] > x for i <= k < j and          *
273*    ptn[j] <= x.  The partition at level 0 is given to nauty by the user.   *
274*    This is  refined for the root of the tree, which has level 1.           *
275*                                                                            *
276*****************************************************************************/
277
278#ifdef BIGNAUTY
279#define NAUTYVERSIONID 2201   /* 1000 times the version number */
280#define NAUTYREQUIRED 2201    /* Minimum compatible version */
281#else
282#define NAUTYVERSIONID 2200
283#define NAUTYREQUIRED 2200
284#endif
285
286#ifndef NAUTY_IN_MAGMA
287#if HAVE_SYSTYPES_H
288#include <sys/types.h>
289#endif
290#if HAVE_UNISTD_H
291#include <unistd.h>
292#endif
293#if HAVE_STDDEF_H
294#include <stddef.h>
295#endif
296#if HAVE_STDLIB_H
297#include <stdlib.h>
298#endif
299#if HAVE_STRING_H
300#include <string.h>
301#else
302#include <strings.h>
303#endif
304#endif
305
306/* WORDSIZE is the number of set elements per setword (16, 32 or 64).
307   Starting at version 2.2, WORDSIZE and setword are defined as follows:
308   If WORDSIZE is so far undefined, use 32 unless longs have more
309      than 32 bits, in which case use 64.
310   Define setword thus:
311      WORDSIZE==16 : unsigned short
312      WORDSIZE==32 : unsigned int unless it is too small,
313			in which case unsigned long
314      WORDSIZE==64 : the first of unsigned int, unsigned long,
315                      unsigned long long, which is large enough.
316*/
317
318#ifdef NAUTY_IN_MAGMA
319#undef WORDSIZE
320#define WORDSIZE WORDBITS
321#endif
322
323#ifdef WORDSIZE
324
325#if  (WORDSIZE != 16) && (WORDSIZE != 32) && (WORDSIZE != 64)
326 #error "WORDSIZE must be 16, 32 or 64"
327#endif
328
329#else  /* WORDSIZE undefined */
330
331#if SIZEOF_LONG>4
332#define WORDSIZE 64
333#else
334#define WORDSIZE 32
335#endif
336
337#endif  /* WORDSIZE */
338
339#if defined(BIGNAUTY) && (WORDSIZE==16)
340 #error "BIGNAUTY requires WORDSIZE 32 or 64"
341#endif
342
343#ifdef NAUTY_IN_MAGMA
344typedef t_uint setword;
345#define SETWORD_INT  /* Don't assume this is correct in Magma. */
346
347#else /* NAUTY_IN_MAGMA */
348
349#if WORDSIZE==16
350typedef unsigned short setword;
351#define SETWORD_SHORT
352#endif
353
354#if WORDSIZE==32
355#if SIZEOF_INT>=4
356typedef unsigned int setword;
357#define SETWORD_INT
358#else
359typedef unsigned long setword;
360#define SETWORD_LONG
361#endif
362#endif
363
364#if WORDSIZE==64
365#if SIZEOF_INT>=8
366typedef unsigned int setword;
367#define SETWORD_INT
368#else
369#if SIZEOF_LONG>=8
370typedef unsigned long setword;
371#define SETWORD_LONG
372#else
373typedef unsigned long long setword;
374#define SETWORD_LONGLONG
375#endif
376#endif
377#endif
378
379#endif /* NAUTY_IN_MAGMA else */
380
381#if WORDSIZE==16
382#define NAUTYVERSION "2.2 (16 bits)"
383#endif
384#if WORDSIZE==32
385#define NAUTYVERSION "2.2 (32 bits)"
386#endif
387#if WORDSIZE==64
388#define NAUTYVERSION "2.2 (64 bits)"
389#endif
390
391#ifndef  MAXN  /* maximum allowed n value; use 0 for dynamic sizing. */
392#define MAXN 0
393#define MAXM 0
394#else
395#define MAXM ((MAXN+WORDSIZE-1)/WORDSIZE)  /* max setwords in a set */
396#endif  /* MAXN */
397
398/* Starting at version 2.2, set operations work for all set sizes unless
399   ONE_WORD_SETS is defined.  In the latter case, if MAXM=1, set ops
400   work only for single-setword sets.  In any case, macro versions
401   ending with 1 work for single-setword sets and versions ending with
402   0 work for all set sizes.
403*/
404
405#if  WORDSIZE==16
406#define SETWD(pos) ((pos)>>4)  /* number of setword containing bit pos */
407#define SETBT(pos) ((pos)&0xF) /* position within setword of bit pos */
408#define TIMESWORDSIZE(w) ((w)<<4)
409#endif
410
411#if  WORDSIZE==32
412#define SETWD(pos) ((pos)>>5)
413#define SETBT(pos) ((pos)&0x1F)
414#define TIMESWORDSIZE(w) ((w)<<5)
415#endif
416
417#if  WORDSIZE==64
418#define SETWD(pos) ((pos)>>6)
419#define SETBT(pos) ((pos)&0x3F)
420#define TIMESWORDSIZE(w) ((w)<<6)    /* w*WORDSIZE */
421#endif
422
423#ifdef NAUTY_IN_MAGMA
424#define BITT bs_bit
425#else
426#define BITT bit
427#endif
428
429#define ADDELEMENT1(setadd,pos)  (*(setadd) |= BITT[pos])
430#define DELELEMENT1(setadd,pos)  (*(setadd) &= ~BITT[pos])
431#define FLIPELEMENT1(setadd,pos) (*(setadd) ^= BITT[pos])
432#define ISELEMENT1(setadd,pos)   ((*(setadd) & BITT[pos]) != 0)
433#define EMPTYSET1(setadd,m)   *(setadd) = 0;
434#define GRAPHROW1(g,v,m) ((set*)(g) + (v))
435
436#define ADDELEMENT0(setadd,pos)  ((setadd)[SETWD(pos)] |= BITT[SETBT(pos)])
437#define DELELEMENT0(setadd,pos)  ((setadd)[SETWD(pos)] &= ~BITT[SETBT(pos)])
438#define FLIPELEMENT0(setadd,pos) ((setadd)[SETWD(pos)] ^= BITT[SETBT(pos)])
439#define ISELEMENT0(setadd,pos) (((setadd)[SETWD(pos)] & BITT[SETBT(pos)]) != 0)
440#define EMPTYSET0(setadd,m) \
441    {setword *es; \
442    for (es = (setword*)(setadd)+(m); --es >= (setword*)(setadd);) *es=0;}
443#define GRAPHROW0(g,v,m) ((set*)(g) + (long)(v)*(long)(m))
444
445#if  (MAXM==1) && defined(ONE_WORD_SETS)
446#define ADDELEMENT ADDELEMENT1
447#define DELELEMENT DELELEMENT1
448#define FLIPELEMENT FLIPELEMENT1
449#define ISELEMENT ISELEMENT1
450#define EMPTYSET EMPTYSET1
451#define GRAPHROW GRAPHROW1
452#else
453#define ADDELEMENT ADDELEMENT0
454#define DELELEMENT DELELEMENT0
455#define FLIPELEMENT FLIPELEMENT0
456#define ISELEMENT ISELEMENT0
457#define EMPTYSET EMPTYSET0
458#define GRAPHROW GRAPHROW0
459#endif
460
461#ifdef NAUTY_IN_MAGMA
462#undef EMPTYSET
463#define EMPTYSET(setadd,m) {t_int _i; bsp_makeempty(setadd,m,_i);}
464#endif
465
466#define NOTSUBSET(word1,word2) ((word1) & ~(word2))  /* test if the 1-bits
467                    in setword word1 do not form a subset of those in word2  */
468#define INTERSECT(word1,word2) ((word1) &= (word2))  /* AND word2 into word1 */
469#define UNION(word1,word2)     ((word1) |= (word2))  /* OR word2 into word1 */
470#define SETDIFF(word1,word2)   ((word1) &= ~(word2)) /* - word2 into word1 */
471#define XOR(word1,word2)       ((word1) ^= (word2))  /* XOR word2 into word1 */
472#define ZAPBIT(word,x) ((word) &= ~BITT[x])  /* delete bit x in setword */
473#define TAKEBIT(iw,w) {iw = FIRSTBIT(w); w ^= BITT[iw];}
474
475#ifdef SETWORD_LONGLONG
476#define MSK3232 0xFFFFFFFF00000000ULL
477#define MSK1648 0xFFFF000000000000ULL
478#define MSK0856 0xFF00000000000000ULL
479#define MSK1632 0x0000FFFF00000000ULL
480#define MSK0840     0xFF0000000000ULL
481#define MSK1616         0xFFFF0000ULL
482#define MSK0824         0xFF000000ULL
483#define MSK0808             0xFF00ULL
484#define MSK63C  0x7FFFFFFFFFFFFFFFULL
485#define MSK31C          0x7FFFFFFFULL
486#define MSK15C              0x7FFFULL
487#define MSK64   0xFFFFFFFFFFFFFFFFULL
488#define MSK32           0xFFFFFFFFULL
489#define MSK16               0xFFFFULL
490#endif
491
492#ifdef SETWORD_LONG
493#define MSK3232 0xFFFFFFFF00000000UL
494#define MSK1648 0xFFFF000000000000UL
495#define MSK0856 0xFF00000000000000UL
496#define MSK1632 0x0000FFFF00000000UL
497#define MSK0840     0xFF0000000000UL
498#define MSK1616         0xFFFF0000UL
499#define MSK0824         0xFF000000UL
500#define MSK0808             0xFF00UL
501#define MSK63C  0x7FFFFFFFFFFFFFFFUL
502#define MSK31C          0x7FFFFFFFUL
503#define MSK15C              0x7FFFUL
504#define MSK64   0xFFFFFFFFFFFFFFFFUL
505#define MSK32           0xFFFFFFFFUL
506#define MSK16               0xFFFFUL
507#endif
508
509#if defined(SETWORD_INT) || defined(SETWORD_SHORT)
510#define MSK3232 0xFFFFFFFF00000000U
511#define MSK1648 0xFFFF000000000000U
512#define MSK0856 0xFF00000000000000U
513#define MSK1632 0x0000FFFF00000000U
514#define MSK0840     0xFF0000000000U
515#define MSK1616         0xFFFF0000U
516#define MSK0824         0xFF000000U
517#define MSK0808             0xFF00U
518#define MSK63C  0x7FFFFFFFFFFFFFFFU
519#define MSK31C          0x7FFFFFFFU
520#define MSK15C              0x7FFFU
521#define MSK64   0xFFFFFFFFFFFFFFFFU
522#define MSK32           0xFFFFFFFFU
523#define MSK16               0xFFFFU
524#endif
525
526#if defined(SETWORD_LONGLONG)
527#if WORDSIZE==16
528#define SETWORD_FORMAT "%04llx"
529#endif
530#if WORDSIZE==32
531#define SETWORD_FORMAT "%08llx"
532#endif
533#if WORDSIZE==64
534#define SETWORD_FORMAT "%16llx"
535#endif
536#endif
537
538#if defined(SETWORD_LONG)
539#if WORDSIZE==16
540#define SETWORD_FORMAT "%04lx"
541#endif
542#if WORDSIZE==32
543#define SETWORD_FORMAT "%08lx"
544#endif
545#if WORDSIZE==64
546#define SETWORD_FORMAT "%16lx"
547#endif
548#endif
549
550#if defined(SETWORD_INT)
551#if WORDSIZE==16
552#define SETWORD_FORMAT "%04x"
553#endif
554#if WORDSIZE==32
555#define SETWORD_FORMAT "%08x"
556#endif
557#if WORDSIZE==64
558#define SETWORD_FORMAT "%16x"
559#endif
560#endif
561
562#if defined(SETWORD_SHORT)
563#if WORDSIZE==16
564#define SETWORD_FORMAT "%04hx"
565#endif
566#if WORDSIZE==32
567#define SETWORD_FORMAT "%08hx"
568#endif
569#if WORDSIZE==64
570#define SETWORD_FORMAT "%16hx"
571#endif
572#endif
573
574/* POPCOUNT(x) = number of 1-bits in a setword x
575   POPCOUNT(x) = number of first 1-bit in non-zero setword (0..WORDSIZE-1)
576   BITMASK(x)  = setword whose rightmost WORDSIZE-x-1 (numbered) bits
577                 are 1 and the rest 0 (0 <= x < WORDSIZE)
578   ALLBITS     = all (numbered) bits in a setword  */
579
580#if  WORDSIZE==64
581#define POPCOUNT(x) (bytecount[(x)>>56 & 0xFF] + bytecount[(x)>>48 & 0xFF] \
582                   + bytecount[(x)>>40 & 0xFF] + bytecount[(x)>>32 & 0xFF] \
583                   + bytecount[(x)>>24 & 0xFF] + bytecount[(x)>>16 & 0xFF] \
584                   + bytecount[(x)>>8 & 0xFF]  + bytecount[(x) & 0xFF])
585#define FIRSTBIT(x) ((x) & MSK3232 ? \
586                       (x) &   MSK1648 ? \
587                         (x) & MSK0856 ? \
588                         0+leftbit[((x)>>56) & 0xFF] : \
589                         8+leftbit[(x)>>48] \
590                       : (x) & MSK0840 ? \
591                         16+leftbit[(x)>>40] : \
592                         24+leftbit[(x)>>32] \
593                     : (x) & MSK1616 ? \
594                         (x) & MSK0824 ? \
595                         32+leftbit[(x)>>24] : \
596                         40+leftbit[(x)>>16] \
597                       : (x) & MSK0808 ? \
598                         48+leftbit[(x)>>8] : \
599                         56+leftbit[x])
600#define BITMASK(x)  (MSK63C >> (x))
601#define ALLBITS  MSK64
602#define SWCHUNK0(w) ((long)((w)>>48)&0xFFFFL)
603#define SWCHUNK1(w) ((long)((w)>>32)&0xFFFFL)
604#define SWCHUNK2(w) ((long)((w)>>16)&0xFFFFL)
605#define SWCHUNK3(w) ((long)(w)&0xFFFFL)
606#endif
607
608#if  WORDSIZE==32
609#define POPCOUNT(x) (bytecount[(x)>>24 & 0xFF] + bytecount[(x)>>16 & 0xFF] \
610                        + bytecount[(x)>>8 & 0xFF] + bytecount[(x) & 0xFF])
611#define FIRSTBIT(x) ((x) & MSK1616 ? ((x) & MSK0824 ? \
612                     leftbit[((x)>>24) & 0xFF] : 8+leftbit[(x)>>16]) \
613                    : ((x) & MSK0808 ? 16+leftbit[(x)>>8] : 24+leftbit[x]))
614#define BITMASK(x)  (MSK31C >> (x))
615#define ALLBITS  MSK32
616#define SWCHUNK0(w) ((long)((w)>>16)&0xFFFFL)
617#define SWCHUNK1(w) ((long)(w)&0xFFFFL)
618#endif
619
620#if  WORDSIZE==16
621#define POPCOUNT(x) (bytecount[(x)>>8 & 0xFF] + bytecount[(x) & 0xFF])
622#define FIRSTBIT(x) ((x) & MSK0808 ? leftbit[((x)>>8) & 0xFF] : 8+leftbit[x])
623#define BITMASK(x)  (MSK15C >> (x))
624#define ALLBITS  MSK16
625#define SWCHUNK0(w) ((long)(w)&0xFFFFL)
626#endif
627
628#ifdef  SYS_CRAY
629#undef POPCOUNT
630#undef FIRSTBIT
631#undef BITMASK
632#define POPCOUNT(x) _popcnt(x)
633#define FIRSTBIT(x) _leadz(x)
634#define BITMASK(x)  _mask(65+(x))
635#endif
636
637#ifdef NAUTY_IN_MAGMA
638#undef POPCOUNT
639#undef FIRSTBIT
640#undef BITMASK
641#define POPCOUNT(x) bs_popcount(x)
642#define FIRSTBIT(x) bs_firstbit(x)
643#define BITMASK(x)  bs_bitmask(x)
644#endif
645
646#define ALLMASK(n) ((n)?~BITMASK((n)-1):(setword)0)  /* First n bits */
647
648    /* various constants: */
649#undef FALSE
650#undef TRUE
651#define FALSE    0
652#define TRUE     1
653
654#ifdef BIGNAUTY
655#define NAUTY_INFINITY 0xFFFFFFF   /* positive int greater than MAXN+2 */
656typedef int shortish;
657#else
658#define NAUTY_INFINITY 0x7FFF      /* positive short int greater than MAXN+2 */
659typedef short shortish;
660#endif
661
662/* For backward compatibility: */
663#if !HAS_MATH_INF && !defined(INFINITY)
664#define INFINITY NAUTY_INFINITY
665#endif
666
667#if MAXN > NAUTY_INFINITY-3
668 #error MAXN must be at most NAUTY_INFINITY-3
669#endif
670
671    /* typedefs for sets, graphs, permutations, etc.: */
672
673typedef int boolean;    /* boolean MUST be the same as int */
674
675#define UPROC void      /* obsolete */
676
677typedef setword set,graph;
678typedef int nvector,np2vector;   /* obsolete */
679typedef shortish permutation;
680#ifdef NAUTY_IN_MAGMA
681typedef graph nauty_graph;
682typedef set nauty_set;
683#endif
684
685typedef struct
686{
687    double grpsize1;        /* size of group is */
688    int grpsize2;           /*    grpsize1 * 10^grpsize2 */
689#define groupsize1 grpsize1     /* for backwards compatibility */
690#define groupsize2 grpsize2
691    int numorbits;          /* number of orbits in group */
692    int numgenerators;      /* number of generators found */
693    int errstatus;          /* if non-zero : an error code */
694#define outofspace errstatus;   /* for backwards compatibility */
695    long numnodes;          /* total number of nodes */
696    long numbadleaves;      /* number of leaves of no use */
697    int maxlevel;           /* maximum depth of search */
698    long tctotal;           /* total size of all target cells */
699    long canupdates;        /* number of updates of best label */
700    long invapplics;        /* number of applications of invarproc */
701    long invsuccesses;      /* number of successful applics of invarproc() */
702    int invarsuclevel;      /* least level where invarproc worked */
703} statsblk;
704
705/* codes for errstatus field (see nauty.c for more accurate descriptions): */
706#define NTOOBIG      1      /* n > MAXN or n > WORDSIZE*m */
707#define MTOOBIG      2      /* m > MAXM */
708#define CANONGNIL    3      /* canong = NULL, but getcanon = TRUE */
709
710/* manipulation of real approximation to group size */
711#define MULTIPLY(s1,s2,i) if ((s1 *= i) >= 1e10) {s1 /= 1e10; s2 += 10;}
712
713typedef struct
714{
715    boolean (*isautom)        /* test for automorphism */
716            (graph*,permutation*,boolean,int,int);
717    int     (*testcanlab)     /* test for better labelling */
718            (graph*,graph*,int*,int*,int,int);
719    void    (*updatecan)      /* update canonical object */
720            (graph*,graph*,permutation*,int,int,int);
721    void    (*refine)         /* refine partition */
722            (graph*,int*,int*,int,int*,permutation*,set*,int*,int,int);
723    void    (*refine1)        /* refine partition, MAXM==1 */
724            (graph*,int*,int*,int,int*,permutation*,set*,int*,int,int);
725    boolean (*cheapautom)     /* test for easy automorphism */
726            (int*,int,boolean,int);
727    int     (*bestcell)       /* find best cell to split */
728            (graph*,int*,int*,int,int,int,int);
729    void    (*freedyn)(void); /* free dynamic memory */
730    void    (*check)          /* check compilation parameters */
731            (int,int,int,int);
732    void    (*dv_spare1)();
733    void    (*dv_spare2)();
734} dispatchvec;
735
736typedef struct
737{
738    int getcanon;             /* make canong and canonlab? */
739#define LABELONLY 2   /* new value UNIMPLEMENTED */
740    boolean digraph;          /* multiple edges or loops? */
741    boolean writeautoms;      /* write automorphisms? */
742    boolean writemarkers;     /* write stats on pts fixed, etc.? */
743    boolean defaultptn;       /* set lab,ptn,active for single cell? */
744    boolean cartesian;        /* use cartesian rep for writing automs? */
745    int linelength;           /* max chars/line (excl. '\n') for output */
746    FILE *outfile;            /* file for output, if any */
747    void (*userrefproc)       /* replacement for usual refine procedure */
748         (graph*,int*,int*,int,int*,permutation*,set*,int*,int,int);
749    void (*userautomproc)     /* procedure called for each automorphism */
750         (int,permutation*,int*,int,int,int);
751    void (*userlevelproc)     /* procedure called for each level */
752         (int*,int*,int,int*,statsblk*,int,int,int,int,int,int);
753    void (*usernodeproc)      /* procedure called for each node */
754         (graph*,int*,int*,int,int,int,int,int,int);
755    void (*usertcellproc)     /* replacement for targetcell procedure */
756         (graph*,int*,int*,int,int,set*,int*,int*,int,int,
757              int(*)(graph*,int*,int*,int,int,int,int),int,int);
758    void (*invarproc)         /* procedure to compute vertex-invariant */
759         (graph*,int*,int*,int,int,int,permutation*,int,boolean,int,int);
760    int tc_level;             /* max level for smart target cell choosing */
761    int mininvarlevel;        /* min level for invariant computation */
762    int maxinvarlevel;        /* max level for invariant computation */
763    int invararg;             /* value passed to (*invarproc)() */
764    dispatchvec *dispatch;    /* vector of object-specific routines */
765#ifdef NAUTY_IN_MAGMA
766    boolean print_stats;      /* CAYLEY specfic - GYM Sep 1990 */
767    char *invarprocname;      /* Magma - no longer global sjc 1994 */
768    int lab_h;                /* Magma - no longer global sjc 1994 */
769    int ptn_h;                /* Magma - no longer global sjc 1994 */
770    int orbitset_h;           /* Magma - no longer global sjc 1994 */
771#endif
772} optionblk;
773
774#ifndef CONSOLWIDTH
775#define CONSOLWIDTH 78
776#endif
777
778/* The following are obsolete.  Just use NULL. */
779#define NILFUNCTION ((void(*)())NULL)      /* nil pointer to user-function */
780#define NILSET      ((set*)NULL)           /* nil pointer to set */
781#define NILGRAPH    ((graph*)NULL)         /* nil pointer to graph */
782
783#define DEFAULTOPTIONS_GRAPH(options) optionblk options = \
784 {0,FALSE,FALSE,FALSE,TRUE,FALSE,CONSOLWIDTH, \
785  NULL,NULL,NULL,NULL,NULL,NULL,NULL,100,0,1,0,&dispatch_graph}
786
787#ifndef DEFAULTOPTIONS
788#define DEFAULTOPTIONS DEFAULTOPTIONS_GRAPH
789#endif
790
791#ifdef NAUTY_IN_MAGMA
792#define PUTC(c,f) io_putchar(c)
793#else
794#ifdef IS_JAVA
795extern void javastream(FILE* f,char c);
796#define PUTC(c,f) javastream(f,c)
797#else
798#define PUTC(c,f) putc(c,f)
799#endif
800#endif
801
802/* We hope that malloc, free, realloc are declared either in <stdlib.h>
803   or <malloc.h>.  Otherwise we will define them.  We also assume that
804   size_t has been defined by the time we get to define malloc(). */
805#ifndef NAUTY_IN_MAGMA
806#if MALLOC_DEC==2
807#include <malloc.h>
808#endif
809#if MALLOC_DEC==0
810extern void *malloc(size_t);
811extern void *realloc(void*,size_t);
812extern void free(void*);
813#endif
814#endif
815
816/* ALLOCS(x,y) should return a pointer (any pointer type) to x*y units of new
817   storage, not necessarily initialised.  A "unit" of storage is defined by
818   the sizeof operator.   x and y are integer values of type int or larger,
819   but x*y may well be too large for an int.  The macro should cast to the
820   correct type for the call.  On failure, ALLOCS(x,y) should return a NULL
821   pointer.  FREES(p) should free storage previously allocated by ALLOCS,
822   where p is the value that ALLOCS returned. */
823
824#ifdef NAUTY_IN_MAGMA
825#define ALLOCS(x,y) mem_malloc((size_t)(x)*(size_t)(y))
826#define REALLOCS(p,x) mem_realloc(p,(size_t)(x))
827#define FREES(p) mem_free(p)
828#else
829#define ALLOCS(x,y) malloc((size_t)(x)*(size_t)(y))
830#define REALLOCS(p,x) realloc(p,(size_t)(x))
831#define FREES(p) free(p)
832#endif
833
834/* The following macros are used by nauty if MAXN=0.  They dynamically
835   allocate arrays of size dependent on m or n.  For each array there
836   should be two static variables:
837     type *name;
838     size_t name_sz;
839   "name" will hold a pointer to an allocated array.  "name_sz" will hold
840   the size of the allocated array in units of sizeof(type).  DYNALLSTAT
841   declares both variables and initialises name_sz=0.  DYNALLOC1 and
842   DYNALLOC2 test if there is enough space allocated, and if not free
843   the existing space and allocate a bigger space.  The allocated space
844   is not initialised.
845
846   In the case of DYNALLOC1, the space is allocated using
847       ALLOCS(sz,sizeof(type)).
848   In the case of DYNALLOC2, the space is allocated using
849       ALLOCS(sz1,sz2*sizeof(type)).
850
851   DYNREALLOC is like DYNALLOC1 except that the old contents are copied
852   into the new space.  realloc() is assumed.  This is not currently
853   used by nauty or dreadnaut.
854
855   DYNFREE frees any allocated array and sets name_sz back to 0.
856   CONDYNFREE does the same, but only if name_sz exceeds some limit.
857*/
858
859#define DYNALLSTAT(type,name,name_sz) \
860	static type *name; static size_t name_sz=0
861#define DYNALLOC1(type,name,name_sz,sz,msg) \
862 if ((size_t)(sz) > name_sz) \
863 { if (name_sz) FREES(name); name_sz = (sz); \
864 if ((name=(type*)ALLOCS(sz,sizeof(type))) == NULL) {alloc_error(msg);}}
865#define DYNALLOC2(type,name,name_sz,sz1,sz2,msg) \
866 if ((size_t)(sz1)*(size_t)(sz2) > name_sz) \
867 { if (name_sz) FREES(name); name_sz = (size_t)(sz1)*(size_t)(sz2); \
868 if ((name=(type*)ALLOCS((sz1),(sz2)*sizeof(type))) == NULL) \
869 {alloc_error(msg);}}
870#define DYNREALLOC(type,name,name_sz,sz,msg) \
871 {if ((size_t)(sz) > name_sz) \
872 { if ((name = (type*)REALLOCS(name,(sz)*sizeof(type))) == NULL) \
873      {alloc_error(msg);} else name_sz = (sz);}}
874#define DYNFREE(name,name_sz) if (name_sz) {FREES(name); name_sz = 0;}
875#define CONDYNFREE(name,name_sz,minsz) \
876 if (name_sz > (size_t)(minsz)) {FREES(name); name_sz = 0;}
877
878/* File to write error messages to (used as first argument to fprintf()). */
879#define ERRFILE stderr
880
881#ifdef OLDEXTDEFS
882#define EXTDEF_CLASS
883#ifdef EXTDEFS
884#define EXTDEF_TYPE 1
885#else
886#define EXTDEF_TYPE 2
887#endif
888#else
889#define EXTDEF_CLASS static
890#define EXTDEF_TYPE 2
891#endif
892
893extern int labelorg;   /* Declared in nautil.c */
894
895#ifndef NAUTY_IN_MAGMA
896  /* Things equivalent to bit, bytecount, leftbit are defined
897     in bs.h for Magma. */
898#if  EXTDEF_TYPE==1
899extern setword bit[];
900extern int bytecount[];
901extern int leftbit[];
902
903#else
904    /* array giving setwords with single 1-bit */
905#if  WORDSIZE==64
906#ifdef SETWORD_LONGLONG
907EXTDEF_CLASS
908setword bit[] = {01000000000000000000000LL,0400000000000000000000LL,
909                 0200000000000000000000LL,0100000000000000000000LL,
910                 040000000000000000000LL,020000000000000000000LL,
911                 010000000000000000000LL,04000000000000000000LL,
912                 02000000000000000000LL,01000000000000000000LL,
913                 0400000000000000000LL,0200000000000000000LL,
914                 0100000000000000000LL,040000000000000000LL,
915                 020000000000000000LL,010000000000000000LL,
916                 04000000000000000LL,02000000000000000LL,
917                 01000000000000000LL,0400000000000000LL,0200000000000000LL,
918                 0100000000000000LL,040000000000000LL,020000000000000LL,
919                 010000000000000LL,04000000000000LL,02000000000000LL,
920                 01000000000000LL,0400000000000LL,0200000000000LL,
921		 0100000000000LL,040000000000LL,020000000000LL,010000000000LL,
922		 04000000000LL,02000000000LL,01000000000LL,0400000000LL,
923		 0200000000LL,0100000000LL,040000000LL,020000000LL,
924		 010000000LL,04000000LL,02000000LL,01000000LL,0400000LL,
925		 0200000LL,0100000LL,040000LL,020000LL,010000LL,04000LL,
926                 02000LL,01000LL,0400LL,0200LL,0100LL,040LL,020LL,010LL,
927		 04LL,02LL,01LL};
928#else
929EXTDEF_CLASS
930setword bit[] = {01000000000000000000000,0400000000000000000000,
931                 0200000000000000000000,0100000000000000000000,
932                 040000000000000000000,020000000000000000000,
933                 010000000000000000000,04000000000000000000,
934                 02000000000000000000,01000000000000000000,
935                 0400000000000000000,0200000000000000000,
936                 0100000000000000000,040000000000000000,020000000000000000,
937                 010000000000000000,04000000000000000,02000000000000000,
938                 01000000000000000,0400000000000000,0200000000000000,
939                 0100000000000000,040000000000000,020000000000000,
940                 010000000000000,04000000000000,02000000000000,
941                 01000000000000,0400000000000,0200000000000,0100000000000,
942                 040000000000,020000000000,010000000000,04000000000,
943                 02000000000,01000000000,0400000000,0200000000,0100000000,
944                 040000000,020000000,010000000,04000000,02000000,01000000,
945                 0400000,0200000,0100000,040000,020000,010000,04000,
946                 02000,01000,0400,0200,0100,040,020,010,04,02,01};
947#endif
948#endif
949
950#if  WORDSIZE==32
951EXTDEF_CLASS
952setword bit[] = {020000000000,010000000000,04000000000,02000000000,
953                 01000000000,0400000000,0200000000,0100000000,040000000,
954                 020000000,010000000,04000000,02000000,01000000,0400000,
955                 0200000,0100000,040000,020000,010000,04000,02000,01000,
956                 0400,0200,0100,040,020,010,04,02,01};
957#endif
958
959#if WORDSIZE==16
960EXTDEF_CLASS
961setword bit[] = {0100000,040000,020000,010000,04000,02000,01000,0400,0200,
962                 0100,040,020,010,04,02,01};
963#endif
964
965    /*  array giving number of 1-bits in bytes valued 0..255: */
966EXTDEF_CLASS
967int bytecount[] = {0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,
968                   1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
969                   1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
970                   2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
971                   1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
972                   2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
973                   2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
974                   3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
975                   1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,
976                   2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
977                   2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
978                   3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
979                   2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,
980                   3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
981                   3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,
982                   4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8};
983
984    /* array giving position (1..7) of high-order 1-bit in byte: */
985EXTDEF_CLASS
986int leftbit[] =   {8,7,6,6,5,5,5,5,4,4,4,4,4,4,4,4,
987                   3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
988                   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
989                   2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
990                   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
991                   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
992                   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
993                   1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
994                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
995                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
996                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
997                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
998                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
999                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1000                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1001                   0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
1002#endif  /* EXTDEFS */
1003
1004#endif /* not NAUTY_IN_MAGMA */
1005
1006#define ANSIPROT 1
1007#define EXTPROC(func,args) extern func args;     /* obsolete */
1008
1009/* The following is for C++ programs that read nauty.h.  Compile nauty
1010   itself using C, not C++.  */
1011
1012#ifdef __cplusplus
1013extern "C" {
1014#endif
1015
1016extern void alloc_error(char*);
1017extern int bestcell(graph*,int*,int*,int,int,int,int);
1018extern void breakout(int*,int*,int,int,int,set*,int);
1019extern boolean cheapautom(int*,int,boolean,int);
1020extern void doref(graph*,int*,int*,int,int*,int*,permutation*,set*,int*,
1021  void(*)(graph*,int*,int*,int,int*,permutation*,set*,int*,int,int),
1022  void(*)(graph*,int*,int*,int,int,int,permutation*,int,boolean,int,int),
1023  int,int,int,boolean,int,int);
1024extern boolean isautom(graph*,permutation*,boolean,int,int);
1025extern dispatchvec dispatch_graph;
1026extern int itos(int,char*);
1027extern void fmperm(permutation*,set*,set*,int,int);
1028extern void fmptn(int*,int*,int,set*,set*,int,int);
1029extern void longprune(set*,set*,set*,set*,int);
1030extern void nauty(graph*,int*,int*,set*,int*,optionblk*,
1031                  statsblk*,set*,int,int,int,graph*);
1032extern int nextelement(set*,int,int);
1033extern int orbjoin(int*,permutation*,int);
1034extern void permset(set*,set*,int,permutation*);
1035extern void putstring(FILE*,char*);
1036extern void refine(graph*,int*,int*,int,int*,permutation*,set*,int*,int,int);
1037extern void refine1(graph*,int*,int*,int,int*,permutation*,set*,int*,int,int);
1038extern void shortprune(set*,set*,int);
1039extern void targetcell(graph*,int*,int*,int,int,set*,int*,
1040         int*,int,int,int(*)(graph*,int*,int*,int,int,int,int),int,int);
1041extern int testcanlab(graph*,graph*,int*,int*,int,int);
1042extern void updatecan(graph*,graph*,permutation*,int,int,int);
1043extern void writeperm(FILE*,permutation*,boolean,int,int);
1044extern void nauty_freedyn(void);
1045extern void nauty_check(int,int,int,int);
1046extern void naugraph_check(int,int,int,int);
1047extern void nautil_check(int,int,int,int);
1048extern void nautil_freedyn(void);
1049extern void naugraph_freedyn(void);
1050
1051#ifdef __cplusplus
1052}
1053#endif
1054
1055#endif  /* _NAUTY_H_ */
1056