/* PermsEquivs.c */
/* Check to see if given permutation from black graph onto red graph makes
       those graphs equivalent */

#include <stdio.h>
void ALTPERM(int*,int);

void main(void)
{
 int 

  PERM[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13},
   I,J,K,M,

 TABLEA[8][9]=
 { {0,0,0,0,0,0,0,0}, {0,0,1,1,0,0,1,1}, {0,1,0,1,1,0,0,1}, {0,1,1,0,1,1,0,0},
   {0,0,1,1,0,1,1,0}, {0,0,0,1,1,0,1,1}, {0,1,0,0,1,1,0,1}, {0,1,1,0,0,1,1,0} },
 TABLEB[8][9]=
 { {0,0,0,0,0,0,0,0}, {0,0,1,0,1,1,0,1}, {0,1,0,1,0,1,1,0}, {0,0,1,0,1,0,1,1},
   {0,1,0,1,0,1,0,1}, {0,1,1,0,1,0,1,0}, {0,0,1,1,0,1,0,1}, {0,1,0,1,1,0,1,0} };


 puts("input a permutation of 1234567:");
 scanf("%d",&K); getchar();
 for (I=7; I>0; I--) {PERM[I]= K%10; K=K/10;}
 for (I=1; I<8; I++) printf("%d ",I); puts("");
 for (I=1; I<8; I++) printf("%d ",PERM[I]); puts("");  getchar();


   M=1;
   for (I=1; I<8; I++)
    for (J=1; J<8; J++) if (TABLEA[I][J] != TABLEB[PERM[I]][PERM[J]])
      {M=0; printf("I=%d J=%d TABLEAIJ=%d  PERMI=%d PERMJ=%d TABLEBPERMIPERMJ=%d\n",
                       I,J,TABLEA[I][J], PERM[I],PERM[J],TABLEB[PERM[I]][PERM[J]]);}
   if (M) puts("Permutation preserves links");
 getchar();
}



