[Nauty] lexicografic ordered canonical form
Sterten at aol.com
Sterten at aol.com
Sat Aug 16 05:23:01 EST 2003
here is, what I'm using. GCC203 , DJGPP in a DOS-Box under Windows 98
I use this batch-file to compile:
gcc -g -c canonize.c
gxx canonize.o nauty.o naugraph.o nautil.o -O2 -o canonize.exe
strip canonize.exe
echo ---------------------- >>canonize.exe
echo ---------------------------------------------------------- >>
canonize.exe
type canonize.c >>canonize.exe
rem these 3 lines are only because I like the source at the end of the
executable
and this canonize.c file :
(BTW. there is also the program labelg included in the nauty-package)
// one graph = adjacency matrix in one line terminated by cr
// -- for UNIX you might have to change 13 to 10 in the goto h04 line
// take care, there is a cr at the end of the file !
#include <stdio.h>
#define MAXN 320
#include "nauty.h"
int main(int argc,char*argv[]) {
FILE *fin;
graph g[MAXN*MAXM];
graph canong[MAXN*MAXM];
nvector lab[MAXN],ptn[MAXN],orbits[MAXN];
static DEFAULTOPTIONS(options);
statsblk(stats);
setword workspace[160*MAXM];
int x,y,z,i,j,n=12,m,v;
char c[320*320];
set *gv;
options.writeautoms = FALSE;
options.writemarkers = FALSE;
options.getcanon = TRUE;
options.defaultptn = TRUE;
options.digraph = TRUE;
if(argc<2){printf("\nusage: canonize infile \n
converts the graphs in infile into canonical members
from their isomorphismclasses and writes these to stdout
format: n*n entries of adjacency matrix ,\n");exit(1);}
if((fin=fopen(argv[1],"rb"))==NULL){printf("file-error");exit(1);}
//printf("los geht's");
h01:i=-1;
h02:j=fgetc(fin);
// printf("%i ",j);
if (feof(fin)){fclose(fin);goto h03;}
if(j==13)goto h04;
if(j<48 || j>49)goto h02;
if(i>320*320){printf("graph too big !\n");goto h03;}
i++;c[i]=j-48;
goto h02;
h04:n=1;
h04f:if(n*n<i){n++;goto h04f;}
//printf("n=%i \n",n);
m=(n+WORDSIZE-1)/WORDSIZE;
for(v=0;v<n;v++){
gv=GRAPHROW(g,v,m);
EMPTYSET(gv,m);
for(i=0;i<n;i++){
if(c[v*n+i])ADDELEMENT(gv,i);}
}
// for(i=1;i<=n;i++)
// {gv=GRAPHROW(g,i-1,m);
// for(j=1;j<=n;j++)printf("%i",ISELEMENT(gv,j-1));}printf("\n");
nauty(g,lab,ptn,NILSET,orbits,&options,&stats,workspace,160*MAXM,m,n,canong);
for(i=1;i<=n;i++)
{gv=GRAPHROW(canong,i-1,m);
for(j=1;j<=n;j++)printf("%i",ISELEMENT(gv,j-1));}printf("\n");
// for(i=1;i<=n;i++)
// {gv=GRAPHROW(g,i-1,m);
// for(j=1;j<=n;j++)printf("%i",ISELEMENT(gv,j-1));}printf("\n");
goto h01;
h03:;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.anu.edu.au/mailman/private/nauty/attachments/20030816/c55e21d5/attachment.html
More information about the Nauty
mailing list