[Nauty] Getting all possible automorphisms from given graph

Sterten at aol.com Sterten at aol.com
Fri Feb 13 21:16:01 EST 2004


//  here is my program which reads adjacency matrices from a file - one per 
line - 
//  and calls nauty to print the size or a list of generators of the 
automorphism group
//  compiled with GCC 2.8.1. DJGPP  in a DOS box under Windows 98


// take care, there is a cr at the end of the file !


#include <stdio.h>
#define MAXN 320
#include "nauty.h"
//int grpsize1,grpsize2;


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,gntk=0;
char c[320*320];
set *gv;
options.writeautoms = TRUE;
options.writeautoms = FALSE;
options.writemarkers = FALSE;
options.getcanon = TRUE;
options.defaultptn = TRUE;
       options.digraph = TRUE;


   if(argc<2){printf("\nusage: gauto infile n\n
          prints automorphismgroup for the graphs in infile
           and writes these to stdout\n
          prints graphsize also, when n>0 is specified\n
          prints generators, when n=42\n
          format: n*n  entries of adjacency matrix ,\n"
          printf("\n\n used NAUTY, which is copyright by Brendan McKay\n\n"
             );exit(1);}

   if((fin=fopen(argv[1],"rb"))==NULL){printf("file-error");exit(1);}
   if(argc=3)sscanf(argv[2],"%i",&gntk);

    if(gntk==42)options.writeautoms = TRUE;

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

j=stats.grpsize1;v=stats.grpsize2;
if(gntk)printf("%i ",n);
printf("%i\n",j);

// 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/20040213/184c6e1a/attachment.html 


More information about the Nauty mailing list