mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
Use free instead of lst_idx=-1
This commit is contained in:
@@ -15,8 +15,13 @@ namespace tc {
|
|||||||
* Rows document the "loops" formed by
|
* Rows document the "loops" formed by
|
||||||
*/
|
*/
|
||||||
struct Row {
|
struct Row {
|
||||||
int gnr = 0; // the number of cosets identified so far
|
bool free = true;
|
||||||
size_t lst_idx = -1; // the index of the coset that would complete the loop
|
|
||||||
|
// the number of cosets identified so far
|
||||||
|
int gnr = 0;
|
||||||
|
|
||||||
|
// the index of the coset that would complete the loop
|
||||||
|
size_t lst_idx = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Tables {
|
struct Tables {
|
||||||
@@ -66,7 +71,6 @@ namespace tc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Coset> lst_vals;
|
std::vector<Coset> lst_vals;
|
||||||
Coset null_lst_idx = 0;
|
|
||||||
rel_tables.add_row();
|
rel_tables.add_row();
|
||||||
for (int table_idx = 0; table_idx < rel_tables.size(); ++table_idx) {
|
for (int table_idx = 0; table_idx < rel_tables.size(); ++table_idx) {
|
||||||
Rel &rel = rel_tables.rels[table_idx];
|
Rel &rel = rel_tables.rels[table_idx];
|
||||||
@@ -75,9 +79,10 @@ namespace tc {
|
|||||||
if (cosets.get(rel.gens[0]) + cosets.get(rel.gens[1]) == -2) {
|
if (cosets.get(rel.gens[0]) + cosets.get(rel.gens[1]) == -2) {
|
||||||
row.lst_idx = lst_vals.size();
|
row.lst_idx = lst_vals.size();
|
||||||
lst_vals.push_back(0);
|
lst_vals.push_back(0);
|
||||||
|
row.free = false;
|
||||||
row.gnr = 0;
|
row.gnr = 0;
|
||||||
} else {
|
} else {
|
||||||
row.lst_idx = null_lst_idx;
|
row.free = false;
|
||||||
row.gnr = -1;
|
row.gnr = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,13 +140,16 @@ namespace tc {
|
|||||||
// Test if loop is closed
|
// Test if loop is closed
|
||||||
Coset other_gen = rel.gens[0] == gen ? rel.gens[1] : rel.gens[0];
|
Coset other_gen = rel.gens[0] == gen ? rel.gens[1] : rel.gens[0];
|
||||||
|
|
||||||
if (trow.lst_idx == -1) {
|
if (trow.free) {
|
||||||
if (target == coset) {
|
if (target == coset) {
|
||||||
trow.gnr = -1;
|
trow.gnr = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
trow.lst_idx = crow.lst_idx;
|
trow = crow;
|
||||||
trow.gnr = crow.gnr + 1;
|
trow.gnr++;
|
||||||
|
// trow.lst_idx = crow.lst_idx;
|
||||||
|
// trow.free = crow.free;
|
||||||
|
// trow.gnr = crow.gnr + 1;
|
||||||
|
|
||||||
if (crow.gnr < 0)
|
if (crow.gnr < 0)
|
||||||
trow.gnr -= 2;
|
trow.gnr -= 2;
|
||||||
@@ -163,19 +171,21 @@ namespace tc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find rows which are still not part of any loop, and assign them to a new loop.
|
// If any target row wasn't identified with a loop,
|
||||||
|
// then assign it a new loop.
|
||||||
for (size_t table_idx = 0; table_idx < rel_tables.size(); table_idx++) {
|
for (size_t table_idx = 0; table_idx < rel_tables.size(); table_idx++) {
|
||||||
auto &rel = rel_tables.rels[table_idx];
|
auto &rel = rel_tables.rels[table_idx];
|
||||||
auto &trow = rel_tables.rows[target][table_idx];
|
auto &trow = rel_tables.rows[target][table_idx];
|
||||||
|
|
||||||
if (trow.lst_idx == -1) {
|
if (trow.free) {
|
||||||
if ((cosets.get(target, rel.gens[0]) != target) and
|
if ((cosets.get(target, rel.gens[0]) != target) and
|
||||||
(cosets.get(target, rel.gens[1]) != target)) {
|
(cosets.get(target, rel.gens[1]) != target)) {
|
||||||
trow.lst_idx = lst_vals.size();
|
trow.lst_idx = lst_vals.size();
|
||||||
|
trow.free = false;
|
||||||
lst_vals.push_back(0);
|
lst_vals.push_back(0);
|
||||||
trow.gnr = 0;
|
trow.gnr = 0;
|
||||||
} else {
|
} else {
|
||||||
trow.lst_idx = null_lst_idx;
|
trow.free = false;
|
||||||
trow.gnr = -1;
|
trow.gnr = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user