-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathffnauty.c
141 lines (105 loc) · 4.67 KB
/
ffnauty.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/* This program prints generators for the automorphism group of an
n-vertex polygon, where n is a number supplied by the user.
This version uses a fixed limit for MAXN.
*/
#define MAXN 1000 /* Define this before including nauty.h */
#include "nauty.h" /* which includes <stdio.h> and other system files */
#include "naututil.h" /* include hashgraph */
void ffnauty(int *coco, int connect[*coco][*coco], int flab[*coco], int color[*coco], int color_true[*coco], int *hash_val1, int *hash_val2, int *hash_val3)
{
graph g[MAXN*MAXM], canong[MAXN*MAXN];
int lab[MAXN],ptn[MAXN],orbits[MAXN], col_true[MAXN];
static DEFAULTOPTIONS_GRAPH(options);
statsblk stats;
int n,m,v,w;
long zseed,colorhash;
/* long hash_val; */
n=*coco;
/* printf("input value of n: %d (from C) \n",n); */
/* Default options are set by the DEFAULTOPTIONS_GRAPH macro above.
Here we change those options that we want to be different from the
defaults. writeautoms=TRUE causes automorphisms to be written. */
/* options.writeautoms = TRUE; */
options.writeautoms = FALSE;
options.defaultptn= FALSE;
options.getcanon= TRUE;
/* The nauty parameter m is a value such that an array of
m setwords is sufficient to hold n bits. The type setword
is defined in nauty.h. The number of bits in a setword is
WORDSIZE, which is 16, 32 or 64. Here we calculate
m = ceiling(n/WORDSIZE). */
m = SETWORDSNEEDED(n);
/* The following optional call verifies that we are linking
to compatible versions of the nauty routines. */
nauty_check(WORDSIZE,m,n,NAUTYVERSIONID);
/* Now we create the cycle. First we zero the graph, than for
each v, we add the edge (v,v+1), where values are mod n. */
EMPTYGRAPH(canong,m,n);
EMPTYGRAPH(g,m,n);
for (v = 0; v < n; ++v) {
for(w=0;w<n; ++w) {
if(connect[w][v]==1) ADDONEEDGE(g,v,w,m);
}
}
/* filling ptn the color vetor*/
for (v = 0; v < n; ++v) {
ptn[v]=color[v];
lab[v]=flab[v];
/* printf("%d -- %d \n",lab[v],ptn[v]); */
col_true[v]=color_true[v];
}
/* printf("Generators for Aut(C[%d]) (from C):\n",n); */
/* we require canonical labelling, NULL pointer is replaced
by the graph type canong*/
densenauty(g,lab,ptn,orbits,&options,&stats,m,n,canong);
/* The size of the group is returned in stats.grpsize1 and
stats.grpsize2. */
/* printf("Automorphism group size = ");
writegroupsize(stdout,stats.grpsize1,stats.grpsize2);
printf("\n"); */
/* print lab, which should be the canonical labelling of vertex in canongraph*/
/* printf("should be canonical lab (from C) \n"); */
for (v = 0; v < n; ++v) {
flab[v] = lab[v];
/* printf("%d,%d \n",v, flab[v]); */
}
/* printf("canong (from C)\n");
for (v=0; v<m*(size_t)n; ++v) {
printf("%lu \n",canong[v]);
}
printf("colors in nauty format\n");
for (v=0;v<n; ++v) {
printf("%d \n", color[v]);
} */
/* Get the hash of color vector, call is: listhash(vector, nx, key), where
nx is the element up to which to get the hash. Also, which key do we use?? */
/* printf("colors in true format\n");
for (v=0;v<n; ++v) {
printf("%d \n", col_true[v]);
} */
/* printf("listhash\n"); */
colorhash = listhash(col_true,n,489317L);
/* printf("%lu \n",colorhash); */
/* printf("listhash\n");
printf("%lu \n",colorhash); */
/* printf("hash1 \n"); */
/* printf("%lu \n",zseed); */
/* Call hashgraph 3 times, like in dreadnaut. Why?
Each time it overwrites the "zseed" value anyway, so why...
Ans: They move around with 3 hash values just in case, I guess. No description
is given in dreadnaut manual.
In order to make final graph hash color dependent, add "colorhash" to the key.
Might aswell just use the "colorhash" as the key itself, no? */
zseed = hashgraph(canong,m,n,2922320L+colorhash);
/* zseed = hashgraph(canong,m,n,colorhash); */
/* printf("%lu \n",zseed); */
*hash_val1 = zseed;
zseed = hashgraph(canong,m,n,19883109L+colorhash);
/* zseed = hashgraph(canong,m,n,colorhash); */
/* printf(" %lu \n",zseed); */
*hash_val2 = zseed;
zseed = hashgraph(canong,m,n,489317L+colorhash);
/* zseed = hashgraph(canong,m,n,colorhash); */
/* printf(" %lu\n",zseed); */
*hash_val3 = zseed;
}