From bcfe181b8e9367e760be3124d4bd90a8cf1c7e0f Mon Sep 17 00:00:00 2001 From: msneddon Date: Sat, 21 Mar 2015 10:39:47 -0700 Subject: [PATCH] patch to nauty for OSX nfsim compilation --- src/nauty24/nausparse.c | 8 +++--- src/nauty24/nausparse.h | 4 +-- src/nauty24/nautil.c | 20 +++++++------- src/nauty24/nauty.c | 54 ++++++++++++++++++------------------- src/nauty24/nauty.h | 60 ++++++++++++++++++++--------------------- src/nauty24/readme.txt | 11 ++++++++ 6 files changed, 84 insertions(+), 73 deletions(-) create mode 100644 src/nauty24/readme.txt diff --git a/src/nauty24/nausparse.c b/src/nauty24/nausparse.c index 92c80526..21f9e630 100644 --- a/src/nauty24/nausparse.c +++ b/src/nauty24/nausparse.c @@ -438,7 +438,7 @@ sortints(int *x, int n) void init_sg(graph *gin, graph **gout, graph *hin, graph **hout, int *lab, - int *ptn, set *active, struct optionstruct *options, int *status, + int *ptn, nset *active, struct optionstruct *options, int *status, int m, int n) { sparsegraph *sg,*sh; @@ -515,7 +515,7 @@ distvals(sparsegraph *g, int v0, shortish *dist, int n) void refine_sg(graph *g, int *lab, int *ptn, int level, int *numcells, - permutation *count, set *active, int *code, int m, int n) + permutation *count, nset *active, int *code, int m, int n) { int i,j,k,l,v1,v2,v3,isplit; shortish w1,w2,w3; @@ -1239,7 +1239,7 @@ sg_to_nauty(sparsegraph *sg, graph *g, int reqm, int *pm) int *v,*d,*e; int m,n,i,j,di; int vi; - set *gi; + nset *gi; SG_VDE(sg,v,d,e); n = sg->nv; @@ -1291,7 +1291,7 @@ nauty_to_sg(graph *g, sparsegraph *sg, int m, int n) int i,j,k; int di,nde; long l; - set *gi; + nset *gi; if (!sg) { diff --git a/src/nauty24/nausparse.h b/src/nauty24/nausparse.h index a4b4446f..5e01fe33 100644 --- a/src/nauty24/nausparse.h +++ b/src/nauty24/nausparse.h @@ -51,10 +51,10 @@ extern int targetcell_sg(graph*,int*,int*,int,int,boolean,int,int,int); extern boolean cheapautom_sg(int*,int,boolean,int); extern boolean isautom_sg(graph*,permutation*,boolean,int,int); extern void - refine_sg(graph*,int*,int*,int,int*,permutation*,set*,int*,int,int); + refine_sg(graph*,int*,int*,int,int*,permutation*,nset*,int*,int,int); extern int testcanlab_sg(graph*,graph*,int*,int*,int,int); extern void updatecan_sg(graph*,graph*,permutation*,int,int,int); -extern void init_sg(graph*,graph**,graph*,graph**,int*,int*,set*, +extern void init_sg(graph*,graph**,graph*,graph**,int*,int*,nset*, struct optionstruct*,int*,int,int); extern void nausparse_freedyn(void); extern void nausparse_check(int,int,int,int); diff --git a/src/nauty24/nautil.c b/src/nauty24/nautil.c index 1464141a..682c0c70 100644 --- a/src/nauty24/nautil.c +++ b/src/nauty24/nautil.c @@ -98,7 +98,7 @@ int labelorg = 0; *****************************************************************************/ int -nextelement(set *set1, int m, int pos) +nextelement(nset *set1, int m, int pos) { setword setwd; int w; @@ -141,7 +141,7 @@ nextelement(set *set1, int m, int pos) *****************************************************************************/ void -permset(set *set1, set *set2, int m, permutation *perm) +permset(nset *set1, nset *set2, int m, permutation *perm) { setword setw; int pos,w,b; @@ -362,7 +362,7 @@ writeperm(FILE *f, permutation *perm, boolean cartesian, int linelength, int n) *****************************************************************************/ void -fmperm(permutation *perm, set *fix, set *mcr, int m, int n) +fmperm(permutation *perm, nset *fix, nset *mcr, int m, int n) { int i,k,l; @@ -408,7 +408,7 @@ fmperm(permutation *perm, set *fix, set *mcr, int m, int n) *****************************************************************************/ void -fmptn(int *lab, int *ptn, int level, set *fix, set *mcr, int m, int n) +fmptn(int *lab, int *ptn, int level, nset *fix, nset *mcr, int m, int n) { int i,lmin; @@ -459,8 +459,8 @@ fmptn(int *lab, int *ptn, int level, set *fix, set *mcr, int m, int n) void doref(graph *g, int *lab, int *ptn, int level, int *numcells, - int *qinvar, permutation *invar, set *active, int *code, - void (*refproc)(graph*,int*,int*,int,int*,permutation*,set*,int*,int,int), + int *qinvar, permutation *invar, nset *active, int *code, + void (*refproc)(graph*,int*,int*,int,int*,permutation*,nset*,int*,int,int), void (*invarproc)(graph*,int*,int*,int,int,int,permutation*, int,boolean,int,int), int mininvarlev, int maxinvarlev, int invararg, @@ -567,7 +567,7 @@ doref(graph *g, int *lab, int *ptn, int level, int *numcells, *****************************************************************************/ void -maketargetcell(graph *g, int *lab, int *ptn, int level, set *tcell, +maketargetcell(graph *g, int *lab, int *ptn, int level, nset *tcell, int *tcellsize, int *cellpos, int tc_level, boolean digraph, int hint, int (*targetcell)(graph*,int*,int*,int,int,boolean,int,int,int), @@ -595,7 +595,7 @@ maketargetcell(graph *g, int *lab, int *ptn, int level, set *tcell, *****************************************************************************/ void -shortprune(set *set1, set *set2, int m) +shortprune(nset *set1, nset *set2, int m) { int i; @@ -616,7 +616,7 @@ shortprune(set *set1, set *set2, int m) void breakout(int *lab, int *ptn, int level, int tc, int tv, - set *active, int m) + nset *active, int m) { int i,prev,next; @@ -649,7 +649,7 @@ breakout(int *lab, int *ptn, int level, int tc, int tv, *****************************************************************************/ void -longprune(set *tcell, set *fix, set *bottom, set *top, int m) +longprune(nset *tcell, nset *fix, nset *bottom, nset *top, int m) { int i; diff --git a/src/nauty24/nauty.c b/src/nauty24/nauty.c index e6f0d656..433f3481 100644 --- a/src/nauty24/nauty.c +++ b/src/nauty24/nauty.c @@ -74,7 +74,7 @@ typedef struct tcnode_struct { struct tcnode_struct *next; - set *tcellptr; + nset *tcellptr; } tcnode; /* aproto: header new_nauty_protos.h */ @@ -149,18 +149,18 @@ static int gca_first, /* level of greatest common ancestor of current static boolean needshortprune; /* used to flag calls to shortprune */ #if !MAXN -DYNALLSTAT(set,defltwork,defltwork_sz); +DYNALLSTAT(nset,defltwork,defltwork_sz); DYNALLSTAT(permutation,workperm,workperm_sz); -DYNALLSTAT(set,fixedpts,fixedpts_sz); +DYNALLSTAT(nset,fixedpts,fixedpts_sz); DYNALLSTAT(permutation,firstlab,firstlab_sz); DYNALLSTAT(permutation,canonlab,canonlab_sz); DYNALLSTAT(short,firstcode,firstcode_sz); DYNALLSTAT(short,canoncode,canoncode_sz); DYNALLSTAT(shortish,firsttc,firsttc_sz); -DYNALLSTAT(set,active,active_sz); +DYNALLSTAT(nset,active,active_sz); /* In the dynamically allocated case (MAXN=0), each level of recursion - needs one set (tcell) to represent the target cell. This is + needs one nset (tcell) to represent the target cell. This is implemented by using a linked list of tcnode anchored at the root of the search tree. Each node points to its child (if any) and to the dynamically allocated tcell. Apart from the the first node of @@ -172,22 +172,22 @@ static tcnode tcnode0 = {NULL,NULL}; static int alloc_m = 0; #else -static set defltwork[2*MAXM]; /* workspace in case none provided */ +static nset defltwork[2*MAXM]; /* workspace in case none provided */ static permutation workperm[MAXN]; /* various scratch uses */ -static set fixedpts[MAXM]; /* points which were explicitly +static nset fixedpts[MAXM]; /* points which were explicitly fixed to get current node */ static permutation firstlab[MAXN], /* label from first leaf */ canonlab[MAXN]; /* label from bsf leaf */ static short firstcode[MAXN+2], /* codes for first leaf */ canoncode[MAXN+2]; /* codes for bsf leaf */ static shortish firsttc[MAXN+2]; /* index of target cell for left path */ -static set active[MAXM]; /* used to contain index to cells now +static nset active[MAXM]; /* used to contain index to cells now active for refinement purposes */ #endif -static set *workspace,*worktop; /* first and just-after-last addresses of +static nset *workspace,*worktop; /* first and just-after-last addresses of work area to hold automorphism data */ -static set *fmptr; /* pointer into workspace */ +static nset *fmptr; /* pointer into workspace */ /***************************************************************************** @@ -201,16 +201,16 @@ static set *fmptr; /* pointer into workspace */ * Parameters - means read-only, means write-only, means both: * * g - the graph * * lab,ptn - used for the partition nest which defines the colouring * -* of g. The initial colouring will be set by the program, * +* of g. The initial colouring will be nset by the program, * * using the same colour for every vertex, if * -* options->defaultptn!=FALSE. Otherwise, you must set it * +* options->defaultptn!=FALSE. Otherwise, you must nset it * * yourself (see the Guide). If options->getcanon!=FALSE, * * the contents of lab on return give the labelling of g * * corresponding to canong. This does not change the * * initial colouring of g as defined by (lab,ptn), since * * the labelling is consistent with the colouring. * * active - If this is not NULL and options->defaultptn==FALSE, * -* it is a set indicating the initial set of active colours. * +* it is a nset indicating the initial nset of active colours. * * See the Guide for details. * * orbits - On return, orbits[i] contains the number of the * * least-numbered vertex in the same orbit as i, for * @@ -235,9 +235,9 @@ static set *fmptr; /* pointer into workspace */ *****************************************************************************/ void -nauty(graph *g_arg, int *lab, int *ptn, set *active_arg, +nauty(graph *g_arg, int *lab, int *ptn, nset *active_arg, int *orbits_arg, optionblk *options, statsblk *stats_arg, - set *ws_arg, int worksize, int m_arg, int n_arg, graph *canong_arg) + nset *ws_arg, int worksize, int m_arg, int n_arg, graph *canong_arg) { int i; int numcells; @@ -328,9 +328,9 @@ nauty(graph *g_arg, int *lab, int *ptn, set *active_arg, OPTCALL(dispatch.check)(WORDSIZE,m,n,NAUTYVERSIONID); #if !MAXN - DYNALLOC1(set,defltwork,defltwork_sz,2*m,"nauty"); - DYNALLOC1(set,fixedpts,fixedpts_sz,m,"nauty"); - DYNALLOC1(set,active,active_sz,m,"nauty"); + DYNALLOC1(nset,defltwork,defltwork_sz,2*m,"nauty"); + DYNALLOC1(nset,fixedpts,fixedpts_sz,m,"nauty"); + DYNALLOC1(nset,active,active_sz,m,"nauty"); DYNALLOC1(permutation,workperm,workperm_sz,n,"nauty"); DYNALLOC1(permutation,firstlab,firstlab_sz,n,"nauty"); DYNALLOC1(permutation,canonlab,canonlab_sz,n,"nauty"); @@ -504,7 +504,7 @@ nauty(graph *g_arg, int *lab, int *ptn, set *active_arg, * * * firstpathnode(lab,ptn,level,numcells) produces a node on the leftmost * * path down the tree. The parameters describe the level and the current * -* colour partition. The set of active cells is taken from the global set * +* colour partition. The nset of active cells is taken from the global nset * * 'active'. If the refined partition is not discrete, the leftmost child * * is produced by calling firstpathnode, and the other children by calling * * othernode. * @@ -530,7 +530,7 @@ firstpathnode(int *lab, int *ptn, int level, int numcells) int tv; int tv1,index,rtnlevel,tcellsize,tc,childcount,qinvar,refcode; #if !MAXN - set *tcell; + nset *tcell; tcnode *tcnode_this; tcnode_this = tcnode_parent->next; @@ -538,14 +538,14 @@ firstpathnode(int *lab, int *ptn, int level, int numcells) { if ((tcnode_this = (tcnode*)ALLOCS(1,sizeof(tcnode))) == NULL || (tcnode_this->tcellptr - = (set*)ALLOCS(alloc_m,sizeof(set))) == NULL) + = (nset*)ALLOCS(alloc_m,sizeof(nset))) == NULL) alloc_error((char *)"tcell"); tcnode_parent->next = tcnode_this; tcnode_this->next = NULL; } tcell = tcnode_this->tcellptr; #else - set tcell[MAXM]; + nset tcell[MAXM]; #endif ++stats->numnodes; @@ -654,7 +654,7 @@ firstpathnode(int *lab, int *ptn, int level, int numcells) * * * othernode(lab,ptn,level,numcells) produces a node other than an ancestor * * of the first leaf. The parameters describe the level and the colour * -* partition. The list of active cells is found in the global set 'active'. * +* partition. The list of active cells is found in the global nset 'active'. * * The value returned is the level to return to. * * * * FUNCTIONS CALLED: (*usernodeproc)(),doref(),refine(),recover(), * @@ -675,7 +675,7 @@ othernode(int *lab, int *ptn, int level, int numcells) int tv1,refcode,rtnlevel,tcellsize,tc,qinvar; short code; #if !MAXN - set *tcell; + nset *tcell; tcnode *tcnode_this; tcnode_this = tcnode_parent->next; @@ -683,14 +683,14 @@ othernode(int *lab, int *ptn, int level, int numcells) { if ((tcnode_this = (tcnode*)ALLOCS(1,sizeof(tcnode))) == NULL || (tcnode_this->tcellptr - = (set*)ALLOCS(alloc_m,sizeof(set))) == NULL) + = (nset*)ALLOCS(alloc_m,sizeof(nset))) == NULL) alloc_error((char *)"tcell"); tcnode_parent->next = tcnode_this; tcnode_this->next = NULL; } tcell = tcnode_this->tcellptr; #else - set tcell[MAXM]; + nset tcell[MAXM]; #endif #ifdef NAUTY_IN_MAGMA @@ -734,7 +734,7 @@ othernode(int *lab, int *ptn, int level, int numcells) } tc = -1; - /* If children will be required, find new target cell and set tc to its + /* If children will be required, find new target cell and nset tc to its position in lab, tcell to its contents, and tcellsize to its size: */ if (numcells < n && (eqlev_first == level || diff --git a/src/nauty24/nauty.h b/src/nauty24/nauty.h index d1ebb5fd..01ecfbe2 100644 --- a/src/nauty24/nauty.h +++ b/src/nauty24/nauty.h @@ -250,7 +250,7 @@ it is necessary to check they are correct. * Conventions and Assumptions: * * * * A 'setword' is the chunk of memory that is occupied by one part of * -* a set. This is assumed to be >= WORDSIZE bits in size. * +* a nset. This is assumed to be >= WORDSIZE bits in size. * * * * The rightmost (loworder) WORDSIZE bits of setwords are numbered * * 0..WORDSIZE-1, left to right. It is necessary that the 2^WORDSIZE * @@ -267,11 +267,11 @@ it is necessary to check they are correct. * is 1 iff x is in the subset. Bits numbered n or greater, and * * unnumbered bits, are assumed permanently zero. * * * -* A 'graph' consists of n contiguous sets. The i-th set represents * +* A 'graph' consists of n contiguous sets. The i-th nset represents * * the vertices adjacent to vertex i, for i = 0,1,...,n-1. * * * * A 'permutation' is an array of n ints repesenting a permutation of * -* the set {0,1,...,n-1}. The value of the i-th entry is the number to * +* the nset {0,1,...,n-1}. The value of the i-th entry is the number to * * which i is mapped. * * * * If g is a graph and p is a permutation, then g^p is the graph in * @@ -310,7 +310,7 @@ it is necessary to check they are correct. #endif #endif -/* WORDSIZE is the number of set elements per setword (16, 32 or 64). +/* WORDSIZE is the number of nset elements per setword (16, 32 or 64). Starting at version 2.2, WORDSIZE and setword are defined as follows: If WORDSIZE is so far undefined, use 32 unless longs have more than 32 bits, in which case use 64. @@ -403,14 +403,14 @@ typedef unsigned long nauty_counter; #define MAXN 0 #define MAXM 0 #else -#define MAXM ((MAXN+WORDSIZE-1)/WORDSIZE) /* max setwords in a set */ +#define MAXM ((MAXN+WORDSIZE-1)/WORDSIZE) /* max setwords in a nset */ #endif /* MAXN */ -/* Starting at version 2.2, set operations work for all set sizes unless +/* Starting at version 2.2, set operations work for all nset sizes unless ONE_WORD_SETS is defined. In the latter case, if MAXM=1, set ops work only for single-setword sets. In any case, macro versions ending with 1 work for single-setword sets and versions ending with - 0 work for all set sizes. + 0 work for all nset sizes. */ #if WORDSIZE==16 @@ -442,7 +442,7 @@ typedef unsigned long nauty_counter; #define FLIPELEMENT1(setadd,pos) (*(setadd) ^= BITT[pos]) #define ISELEMENT1(setadd,pos) ((*(setadd) & BITT[pos]) != 0) #define EMPTYSET1(setadd,m) *(setadd) = 0; -#define GRAPHROW1(g,v,m) ((set*)(g) + (v)) +#define GRAPHROW1(g,v,m) ((nset*)(g) + (v)) #define ADDELEMENT0(setadd,pos) ((setadd)[SETWD(pos)] |= BITT[SETBT(pos)]) #define DELELEMENT0(setadd,pos) ((setadd)[SETWD(pos)] &= ~BITT[SETBT(pos)]) @@ -451,7 +451,7 @@ typedef unsigned long nauty_counter; #define EMPTYSET0(setadd,m) \ {setword *es; \ for (es = (setword*)(setadd)+(m); --es >= (setword*)(setadd);) *es=0;} -#define GRAPHROW0(g,v,m) ((set*)(g) + (long)(v)*(long)(m)) +#define GRAPHROW0(g,v,m) ((nset*)(g) + (long)(v)*(long)(m)) #if (MAXM==1) && defined(ONE_WORD_SETS) #define ADDELEMENT ADDELEMENT1 @@ -686,12 +686,12 @@ typedef int boolean; /* boolean MUST be the same as int */ #define UPROC void /* obsolete */ -typedef setword set,graph; +typedef setword nset,graph; typedef int nvector,np2vector; /* obsolete */ typedef shortish permutation; #ifdef NAUTY_IN_MAGMA typedef graph nauty_graph; -typedef set nauty_set; +typedef nset nauty_set; #endif typedef struct @@ -733,9 +733,9 @@ typedef struct void (*updatecan) /* update canonical object */ (graph*,graph*,permutation*,int,int,int); void (*refine) /* refine partition */ - (graph*,int*,int*,int,int*,permutation*,set*,int*,int,int); + (graph*,int*,int*,int,int*,permutation*,nset*,int*,int,int); void (*refine1) /* refine partition, MAXM==1 */ - (graph*,int*,int*,int,int*,permutation*,set*,int*,int,int); + (graph*,int*,int*,int,int*,permutation*,nset*,int*,int,int); boolean (*cheapautom) /* test for easy automorphism */ (int*,int,boolean,int); int (*targetcell) /* decide which cell to split */ @@ -743,7 +743,7 @@ typedef struct void (*freedyn)(void); /* free dynamic memory */ void (*check) /* check compilation parameters */ (int,int,int,int); - void (*init)(graph*,graph**,graph*,graph**,int*,int*,set*, + void (*init)(graph*,graph**,graph*,graph**,int*,int*,nset*, struct optionstruct*,int*,int,int); void (*cleanup)(graph*,graph**,graph*,graph**,int*,int*, struct optionstruct*,statsblk*,int,int); @@ -761,7 +761,7 @@ typedef struct optionstruct int linelength; /* max chars/line (excl. '\n') for output */ FILE *outfile; /* file for output, if any */ void (*userrefproc) /* replacement for usual refine procedure */ - (graph*,int*,int*,int,int*,permutation*,set*,int*,int,int); + (graph*,int*,int*,int,int*,permutation*,nset*,int*,int,int); void (*userautomproc) /* procedure called for each automorphism */ (int,permutation*,int*,int,int,int); void (*userlevelproc) /* procedure called for each level */ @@ -791,7 +791,7 @@ typedef struct optionstruct /* The following are obsolete. Just use NULL. */ #define NILFUNCTION ((void(*)())NULL) /* nil pointer to user-function */ -#define NILSET ((set*)NULL) /* nil pointer to set */ +#define NILSET ((nset*)NULL) /* nil pointer to nset */ #define NILGRAPH ((graph*)NULL) /* nil pointer to graph */ #define DEFAULTOPTIONS_GRAPH(options) optionblk options = \ @@ -1029,10 +1029,10 @@ extern "C" { #endif extern void alloc_error(char*); -extern void breakout(int*,int*,int,int,int,set*,int); +extern void breakout(int*,int*,int,int,int,nset*,int); extern boolean cheapautom(int*,int,boolean,int); -extern void doref(graph*,int*,int*,int,int*,int*,permutation*,set*,int*, - void(*)(graph*,int*,int*,int,int*,permutation*,set*,int*,int,int), +extern void doref(graph*,int*,int*,int,int*,int*,permutation*,nset*,int*, + void(*)(graph*,int*,int*,int,int*,permutation*,nset*,int*,int,int), void(*)(graph*,int*,int*,int,int,int,permutation*,int,boolean,int,int), int,int,int,boolean,int,int); extern void extra_autom(permutation*,int); @@ -1040,20 +1040,20 @@ extern void extra_level(int,int*,int*,int,int,int,int,int,int); extern boolean isautom(graph*,permutation*,boolean,int,int); extern dispatchvec dispatch_graph; extern int itos(int,char*); -extern void fmperm(permutation*,set*,set*,int,int); -extern void fmptn(int*,int*,int,set*,set*,int,int); -extern void longprune(set*,set*,set*,set*,int); -extern void nauty(graph*,int*,int*,set*,int*,optionblk*, - statsblk*,set*,int,int,int,graph*); -extern void maketargetcell(graph*,int*,int*,int,set*,int*,int*,int,boolean, +extern void fmperm(permutation*,nset*,nset*,int,int); +extern void fmptn(int*,int*,int,nset*,nset*,int,int); +extern void longprune(nset*,nset*,nset*,nset*,int); +extern void nauty(graph*,int*,int*,nset*,int*,optionblk*, + statsblk*,nset*,int,int,int,graph*); +extern void maketargetcell(graph*,int*,int*,int,nset*,int*,int*,int,boolean, int,int (*)(graph*,int*,int*,int,int,boolean,int,int,int),int,int); -extern int nextelement(set*,int,int); +extern int nextelement(nset*,int,int); extern int orbjoin(int*,permutation*,int); -extern void permset(set*,set*,int,permutation*); +extern void permset(nset*,nset*,int,permutation*); extern void putstring(FILE*,char*); -extern void refine(graph*,int*,int*,int,int*,permutation*,set*,int*,int,int); -extern void refine1(graph*,int*,int*,int,int*,permutation*,set*,int*,int,int); -extern void shortprune(set*,set*,int); +extern void refine(graph*,int*,int*,int,int*,permutation*,nset*,int*,int,int); +extern void refine1(graph*,int*,int*,int,int*,permutation*,nset*,int*,int,int); +extern void shortprune(nset*,nset*,int); extern int targetcell(graph*,int*,int*,int,int,boolean,int,int,int); extern int testcanlab(graph*,graph*,int*,int*,int,int); extern void updatecan(graph*,graph*,permutation*,int,int,int); diff --git a/src/nauty24/readme.txt b/src/nauty24/readme.txt new file mode 100644 index 00000000..acda3d42 --- /dev/null +++ b/src/nauty24/readme.txt @@ -0,0 +1,11 @@ + + +Nauty v2.4 is an open-source package used for canonical graph labeling in the populations feature of NFsim. +see: http://cs.anu.edu.au/~bdm/nauty/ + +This code has been patched by renaming the typedef 'set' to 'nset', as set conflicts +with the c++ std::set and generates compiler errors in the most recent releases of +x code on OSX. Earlier versions of x code and current versions of Linux gcc have no +such proble. There is likely a better fix, but as a quick patch to get things +running in OSX, this works perfectly fine. +