Orbiter 2022
Combinatorial Objects
girth_test.cpp
Go to the documentation of this file.
1/*
2 * girth_test.cpp
3 *
4 * Created on: Nov 18, 2021
5 * Author: betten
6 */
7
8
9
10
11#include "foundations.h"
12
13using namespace std;
14
15
16
17namespace orbiter {
18namespace layer1_foundations {
19namespace geometry_builder {
20
21
22
24{
25 gg = NULL;
26 girth = 0;
27 V = 0;
28 S = NULL;
29 D = NULL;
30}
31
33{
34 int i;
35
36 if (S) {
37 for (i = 0; i < V; i++) {
38 FREE_int(S[i]);
39 FREE_int(D[i]);
40 }
41 FREE_pint(S);
42 FREE_pint(D);
43 }
44}
45
46void girth_test::init(gen_geo *gg, int girth, int verbose_level)
47{
48 int f_v = (verbose_level >= 1);
49 int i;
50
51 if (f_v) {
52 cout << "girth_test::init" << endl;
53 }
54
57 V = gg->GB->V;
58
59 S = NEW_pint(V);
60 D = NEW_pint(V);
61 for (i = 0; i < V; i++) {
62 S[i] = NEW_int(V * V);
63 D[i] = NEW_int(V * V);
64 }
65
66
67 if (f_v) {
68 cout << "girth_test::init done" << endl;
69 }
70}
71
72void girth_test::Floyd(int row, int verbose_level)
73{
74 int f_v = (verbose_level >= 1);
75 int i, j, k, a;
76
77 if (f_v) {
78 cout << "girth_test::Floyd" << endl;
79 }
80 if (row == 0) {
81 Int_vec_zero(D[0], V * V);
82 }
83 else {
84 Int_vec_copy(D[row - 1], D[row], V * V);
85 }
86
87 // set all connected positions to 1
88 // and all unconnected positions to infinity:
89
90 for (i = 0; i < V; i++) {
91 for (j = 0; j < V; j++) {
92 if (i == j) {
93 S[row][i * V + j] = 0;
94 }
95 if (D[row][i * V + j] == 0) {
96 S[row][i * V + j] = 9999; // Does this look like infinity?
97 }
98 else {
99 S[row][i * V + j] = 1;
100 }
101 }
102 }
103
104 // for each route via k from i to j pick any better routes and
105 // replace i-j path with sum of paths i-k and j-k
106
107 for (k = 0; k < V; k++) {
108 for (i = 0; i < V; i++) {
109 for (j = 0; j < V; j++) {
110
111 a = S[row][i * V + k] + S[row][k * V + j];
112
113 if (a < S[row][i * V + j] ) {
114 S[row][i * V + j] = a;
115 }
116 }
117 }
118 }
119
120
121 if (f_v) {
122 cout << "girth_test::Floyd done" << endl;
123 }
124
125}
126
127void girth_test::add_incidence(int i, int j_idx, int j)
128{
129 int h, a;
130
131 for (h = 0; h < gg->inc->K[j]; h++) {
132 a = gg->inc->theY[j][h];
133 //cout << "girth_test::add_incidence a=" << a << " i=" << i << endl;
134 D[i][a * V + i] = 1;
135 D[i][i * V + a] = 1;
136 }
137}
138
139void girth_test::delete_incidence(int i, int j_idx, int j)
140{
141 int h, a;
142
143 for (h = 0; h < gg->inc->K[j]; h++) {
144 a = gg->inc->theY[j][h];
145 D[i][a * V + i] = 0;
146 D[i][i * V + a] = 0;
147 }
148}
149
150int girth_test::check_girth_condition(int i, int j_idx, int j, int verbose_level)
151{
152 int h, dim_n, j1, u1, u2, a1, a2;
153 int f_v = (verbose_level >= 1);
154
155 if (f_v) {
156 cout << "girth_test::check_girth_condition i = " << i << ", j = " << j << endl;
157 }
158 dim_n = gg->inc->Encoding->dim_n;
159 for (h = 0; h < j_idx; h++) {
160 j1 = gg->inc->Encoding->theX_ir(i, h);
161 for (u1 = 0; u1 < gg->inc->K[j1]; u1++) {
162 a1 = gg->inc->theY[j1][u1];
163 if (a1 == i) {
164 continue;
165 }
166 for (u2 = 0; u2 < gg->inc->K[j]; u2++) {
167 a2 = gg->inc->theY[j][u2];
168 if (a2 == a1) {
169 continue;
170 }
171 if (a1 == i) {
172 continue;
173 }
174 if (S[i][a1 * V + a2] + 2 < girth) {
175 if (f_v) {
176 cout << "girth_test::check_girth_condition reject:" << endl;
177 cout << "a1 = " << a1 << ", a2 = " << a2 << ", and nb_completed_rows = " << i << endl;
178 cout << "path from a1 to a2 = " << S[i][a1 * V + a2] << ", and girth = " << girth << endl;
179 }
180 return FALSE;
181 }
182 }
183 }
184 }
185 if (f_v) {
186 cout << "girth_test::check_girth_condition OK" << endl;
187 }
188 return TRUE;
189}
190
192{
193 cout << "S[" << i << "]:" << endl;
194 Int_matrix_print(S[i], V, V);
195}
196
198{
199 cout << "D[" << i << "]:" << endl;
200 Int_matrix_print(D[i], V, V);
201}
202
203}}}
204
205
classification of geometries with a given row-tactical decomposition
int check_girth_condition(int i, int j_idx, int j, int verbose_level)
Definition: girth_test.cpp:150
void init(gen_geo *gg, int girth, int verbose_level)
Definition: girth_test.cpp:46
#define FREE_int(p)
Definition: foundations.h:640
#define Int_vec_zero(A, B)
Definition: foundations.h:713
#define NEW_pint(n)
Definition: foundations.h:627
#define NEW_int(n)
Definition: foundations.h:625
#define Int_matrix_print(A, B, C)
Definition: foundations.h:707
#define TRUE
Definition: foundations.h:231
#define FALSE
Definition: foundations.h:234
#define Int_vec_copy(A, B, C)
Definition: foundations.h:693
#define FREE_pint(p)
Definition: foundations.h:641
the orbiter library for the classification of combinatorial objects