Output bugfix

This commit is contained in:
Florian Stecker 2016-11-07 17:22:16 +01:00
parent 8c21410dda
commit 03854910b9
2 changed files with 14 additions and 21 deletions

22
test.c
View File

@ -107,7 +107,7 @@ int main(int argc, const char *argv[])
for(int i = 0; i < order; i++)
reduced[i] = reduced[group[i]];
// count cosets
// step 4: assign indices to cosets
ncosets = 0;
for(int i = 0; i < order; i++)
if(reduced[i] == i)
@ -124,7 +124,7 @@ int main(int argc, const char *argv[])
seen = (int*) malloc(ncosets*sizeof(int));
edgelists_simplified_used = 0;
// copy minima
// step 5: set up nodes from minima
current = 0;
for(int i = 0; i < order; i++)
if(reduced[i] == i) { // is minimum
@ -139,7 +139,7 @@ int main(int argc, const char *argv[])
for(int i = 0; i < ncosets; i++)
fprintf(stderr, "%s <=> %s\n", simplified_graph[i].wordlength == 0 ? "1" : alphabetize(simplified_graph[i].word, simplified_graph[i].wordlength, alphabet, buffer), simplified_graph[simplified_graph[i].opposite].wordlength == 0 ? "1" : alphabetize(simplified_graph[simplified_graph[i].opposite].word, simplified_graph[simplified_graph[i].opposite].wordlength, alphabet, buffer2));
// find order relations
// step 6: find order relations
for(int i = 0; i < order; i++) {
edge = graph[i].bruhat_lower;
while(edge) {
@ -149,8 +149,6 @@ int main(int argc, const char *argv[])
// found something
if(!edgelist_contains(simplified_graph[this].bruhat_lower, that))
simplified_graph[this].bruhat_lower = edgelist_add(simplified_graph[this].bruhat_lower, that, edgelists_simplified, &edgelists_simplified_used);
// if(!edgelist_contains(simplified_graph[that].bruhat_higher, this))
// simplified_graph[that].bruhat_higher = edgelist_add(simplified_graph[that].bruhat_higher, this, edgelists_simplified, &edgelists_simplified_used);
ERROR(simplified_graph[this].wordlength <= simplified_graph[that].wordlength, "The order assumption is being violated!\n");
}
edge = edge->next;
@ -159,7 +157,7 @@ int main(int argc, const char *argv[])
fprintf(stderr, "\nAdded %d edges.\n\n", edgelists_simplified_used);
// remove redundant edges
// step 7: remove redundant edges
for(int i = 0; i < ncosets; i++) {
memset(seen, 0, ncosets*sizeof(int));
queue_init(&queue);
@ -203,7 +201,7 @@ int main(int argc, const char *argv[])
}
}
// reverse order
// step 8: revert order
for(int i = 0; i < ncosets; i++) {
edge = simplified_graph[i].bruhat_lower;
while(edge) {
@ -214,9 +212,8 @@ int main(int argc, const char *argv[])
}
}
// output as graphviz dot file
fprintf(stdout, "digraph test123 {\n");
for(int i = 0; i < ncosets; i++) {
edge = simplified_graph[i].bruhat_lower;
while(edge) {
@ -227,19 +224,12 @@ int main(int argc, const char *argv[])
edge = edge->next;
}
}
fprintf(stdout, "}\n");
long nthickenings = enumerate_balanced_thickenings(type, simplified_graph, ncosets, alphabet, stdout);
fprintf(stderr, "Found %ld balanced thickenings.\n", nthickenings);
/* for(int i = 0; i < order; i++)
printf("%s <= %s\n",
reduced[i] == 0 ? "1" : alphabetize(graph[reduced[i]].word, graph[reduced[i]].wordlength, alphabet, buffer2),
i == 0 ? "1" : alphabetize(graph[i].word, graph[i].wordlength, alphabet, buffer)); */
free(seen);
free(simplified_graph);
free(edgelists_simplified);

View File

@ -365,19 +365,22 @@ static long enumerate_tree(const enumeration_info_t *info, signed char *level, i
level[head] = HEAD_MARKER;
int is_slim = transitive_closure(info, level, head, current_level);
int is_fat;
int is_balanced = 0;
int count = 0;
// we have a candidate, check if it is a balanced thickening; if so, write to stdout
if(is_slim) {
is_fat = 1;
is_balanced = 1;
for(int i = head - 1; i >= 0; i--)
if(level[i] == 0)
is_fat = 0;
is_balanced = 0;
}
output_thickening(info, level, current_level, is_slim, is_fat, count);
// comment this out (or just put it inside the if block) to save 1/3 of the runtime
output_thickening(info, level, current_level, is_slim, is_balanced, count);
if(is_fat) {
if(is_slim) {
if(is_balanced) {
count++;
fwrite(level, sizeof(signed char), info->size, info->outfile);
} else {