Orbiter 2022
Combinatorial Objects
nauty_output.cpp
Go to the documentation of this file.
1/*
2 * nauty_output.cpp
3 *
4 * Created on: Aug 21, 2021
5 * Author: betten
6 */
7
8
9#include "foundations.h"
10
11
12using namespace std;
13
14
15namespace orbiter {
16namespace layer1_foundations {
17namespace data_structures {
18
19
21{
22 N = 0;
23 Aut = NULL;
24 Aut_counter = 0;
25 Base = NULL;
26 Base_length = 0;
27 Base_lint = NULL;
28 Transversal_length = NULL;
29 Ago = NULL;
30
31 canonical_labeling = NULL;
32
34 nb_othernode = 0;
37}
38
40{
41 //cout << "nauty_output::~nauty_output" << endl;
42 if (Aut) {
43 //cout << "before FREE_int(Aut);" << endl;
45 }
46 if (Base) {
47 //cout << "before FREE_int(Base);" << endl;
49 }
50 if (Base_lint) {
51 //cout << "before FREE_lint(Base_lint);" << endl;
53 }
55 //cout << "before FREE_int(Transversal_length);" << endl;
57 }
58 if (Ago) {
59 //cout << "before FREE_OBJECT(Ago);" << endl;
61 }
63 //cout << "before FREE_int(canonical_labeling);" << endl;
65 }
66 //cout << "nauty_output::~nauty_output done" << endl;
67}
68
69void nauty_output::allocate(int N, int verbose_level)
70{
71 int f_v = (verbose_level >= 1);
72
73 if (f_v) {
74 cout << "nauty_output::allocate" << endl;
75 }
77
78 Aut = NEW_int(N * N);
79 Base = NEW_int(N);
84
85 int i;
86
87 for (i = 0; i < N; i++) {
88 canonical_labeling[i] = i;
89 }
90}
91
93{
94 cout << "nauty_output::print" << endl;
95 cout << "N=" << N << endl;
96}
97
99{
100 cout << "nb_backtrack1 = " << nb_firstpathnode << endl;
101 cout << "nb_backtrack2 = " << nb_othernode << endl;
102 cout << "nb_backtrack3 = " << nb_processnode << endl;
103 cout << "nb_backtrack4 = " << nb_firstterminal << endl;
104
105}
106
107int nauty_output::belong_to_the_same_orbit(int a, int b, int verbose_level)
108{
109 int f_v = (verbose_level >= 1);
110
111 if (f_v) {
112 cout << "nauty_output::belong_to_the_same_orbit" << endl;
113 }
114
115 int *prev;
116 int *orbit;
117 int *Q;
118 int Q_len;
119 int orbit_len;
120 int c, d;
121 int i, j;
122 int nb_gen;
123
124 nb_gen = Aut_counter;
125 prev = NEW_int(N);
126 orbit = NEW_int(N);
127 Q = NEW_int(N);
128 Q[0] = a;
129 Q_len = 1;
130 orbit_len = 0;
131 prev[a] = a;
132
133 for (i = 0; i < N; i++) {
134 prev[i] = -1;
135 }
136
137 while (Q_len) {
138 c = Q[0];
139 for (i = 1; i < Q_len; i++) {
140 Q[i - 1] = Q[i];
141 }
142 Q_len--;
143 orbit[orbit_len++] = c;
144 for (j = 0; j < nb_gen; j++) {
145 d = Aut[j * N + c];
146 if (prev[d] == -1) {
147 prev[d] = c;
148 Q[Q_len++] = d;
149 if (d == b) {
150 FREE_int(prev);
151 FREE_int(orbit);
152 FREE_int(Q);
153 return TRUE;
154 }
155 }
156 }
157 }
158
159 if (f_v) {
160 cout << "nauty_output::belong_to_the_same_orbit done" << endl;
161 }
162 return FALSE;
163}
164
165
166
167
168}}}
169
int belong_to_the_same_orbit(int a, int b, int verbose_level)
a class to represent arbitrary precision integers
Definition: ring_theory.h:366
#define FREE_int(p)
Definition: foundations.h:640
#define NEW_OBJECT(type)
Definition: foundations.h:638
#define FREE_OBJECT(p)
Definition: foundations.h:651
#define NEW_int(n)
Definition: foundations.h:625
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define FREE_lint(p)
Definition: foundations.h:642
#define NEW_lint(n)
Definition: foundations.h:628
the orbiter library for the classification of combinatorial objects