[Nauty] Re: nauty-list digest, Vol 1 #51 - 2 msgs

Sterten at aol.com Sterten at aol.com
Sun Feb 1 07:10:01 EST 2004


 >Hi:
 >    Thank you for your response.
 >    However I am not still sure I understand this completely.
 >    Can you send me some sample code and a pointer for detailed
 >    explanation.
 >    I read the NAUTY manual but I am not sure where the realted info is.
 >
 >    thanks,
 >    Wahid.

there is also a file  "labelg.c"  which comes with the Nauty package.
Maybe this does what you want, I'm not sure.

I wrote my own program which I called "canonize.c" ,
which reads and prints just the n*n values of the adjacency matrices,
one graph per line.
I compiled it under Windows98 + GCC203 + DJGPP 
with this batch file:

gcc -g -c canonize.c 
gxx canonize.o nauty.o naugraph.o nautil.o -O2 -o canonize.exe 

below is the C-sourcecode , mail me if you want an executable,
running under DOS.

BTW., I also made an executable recently which prints
the size of the automorphism group or its generators.
I can also send it or post it, if somebody is interested.


Guenter


// --------------------------------------------------------------------
// take care, that there is a line feed (=ASCII 10) at the end
//  of the graph-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\n
          converts the graphs in infile into canonical members\n
           from their isomorphismclasses and writes these to stdout\n
          format: n*n  entries of adjacency matrix \n
           followed by line feed (ASCII 10) \n\n\n\n
          uses NAUTY, which is copyright by Brendan McKay\n");
           exit(1);}

   if((fin=fopen(argv[1],"rb"))==NULL){printf("file-error");exit(1);}

h01:i=-1;
h02:j=fgetc(fin);
    if (feof(fin)){fclose(fin);goto h03;}
    if(j==10)goto h04;
    if(j<48 || j>49)goto h02;
    if(i>320*320){printf("graph is too big !\n");goto h03;}
    i++;c[i]=j-48;
goto h02;

h04:n=1;
   h04f:if(n*n<i){n++;goto h04f;}

  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);}
  } 

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");

  goto h01;
  h03:;
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.anu.edu.au/mailman/private/nauty/attachments/20040201/c9cf50d5/attachment.html 


More information about the Nauty mailing list