color principal ideals

This commit is contained in:
Florian Stecker 2025-03-08 11:56:27 -05:00
parent 49f64f509b
commit 0f23a4b477

55
graph.c
View File

@ -1,12 +1,11 @@
#include "weyl.h"
#include "queue.h" #include "queue.h"
#include "weyl.h"
#include <strings.h>
#include <stdio.h>
#include <memory.h> #include <memory.h>
#include <stdio.h>
#include <strings.h>
static char* alphabetize(weylgroup_element_t *e, char *str) static char *alphabetize(weylgroup_element_t *e, char *str) {
{
if (e->wordlength == 0) if (e->wordlength == 0)
sprintf(str, "1"); sprintf(str, "1");
else { else {
@ -18,8 +17,7 @@ static char* alphabetize(weylgroup_element_t *e, char *str)
return str; return str;
} }
int main(int argc, const char *argv[]) int main(int argc, const char *argv[]) {
{
semisimple_type_t type; semisimple_type_t type;
unsigned long right_invariance, left_invariance; unsigned long right_invariance, left_invariance;
doublequotient_t *dq; doublequotient_t *dq;
@ -40,7 +38,9 @@ int main(int argc, const char *argv[])
for (int i = 0; i < type.n; i++) { for (int i = 0; i < type.n; i++) {
type.factors[i].series = argv[i + 1][0]; type.factors[i].series = argv[i + 1][0];
type.factors[i].rank = argv[i + 1][1] - '0'; type.factors[i].rank = argv[i + 1][1] - '0';
ERROR(argv[i+1][0] < 'A' || argv[i+1][0] > 'G' || argv[i+1][1] < '1' || argv[i+1][1] > '9', "Arguments must be Xn with X out of A-G and n out of 1-9\n"); ERROR(argv[i + 1][0] < 'A' || argv[i + 1][0] > 'G' ||
argv[i + 1][1] < '1' || argv[i + 1][1] > '9',
"Arguments must be Xn with X out of A-G and n out of 1-9\n");
} }
left_invariance = right_invariance = 0; left_invariance = right_invariance = 0;
@ -55,18 +55,45 @@ int main(int argc, const char *argv[])
} }
// generate graph // generate graph
dq = weyl_generate_bruhat(type, left_invariance, right_invariance); dq = weyl_generate_bruhat(type, left_invariance, right_invariance);
fprintf(stdout, "digraph test123 {\n"); // color ideals
for(int i = 0; i < dq->count; i++) int *color = (int*) malloc(dq->count * sizeof(int));
for(doublecoset_list_t *current = dq->cosets[i].bruhat_lower; current; current = current->next) memset(color, 0, dq->count * sizeof(int));
fprintf(stdout, "%s -> %s;\n", for(int i = type.n+3; i < argc; i++) {
weylgroup_element_t *elem = &dq->group[0]; // identity
for(int j = 0; j < strlen(argv[i]); j++) {
int gen = argv[i][j] - 'a';
elem = elem->right[gen];
}
color[elem->coset->index] = 1;
}
for(int i = dq->count - 1; i >= 0; i--) {
if(color[i] > 0) {
for(doublecoset_list_t *current = dq->cosets[i].bruhat_lower; current; current = current->next) {
color[current->to->index] = color[i];
}
}
}
fprintf(stdout, "digraph bruhat {\n");
for (int i = 0; i < dq->count; i++) {
fprintf(stdout, "%s [color=\"%s\"];\n",
alphabetize(dq->cosets[i].min, stringbuffer), alphabetize(dq->cosets[i].min, stringbuffer),
alphabetize(current->to->min, stringbuffer2)); color[i] > 0 ? "red" : "black");
for (doublecoset_list_t *current = dq->cosets[i].bruhat_lower; current; current = current->next) {
fprintf(stdout, "%s -> %s [color=\"%s\"];\n",
alphabetize(dq->cosets[i].min, stringbuffer),
alphabetize(current->to->min, stringbuffer2),
color[i] > 0 ? "red" : "black");
}
}
fprintf(stdout, "}\n\n"); fprintf(stdout, "}\n\n");
// clean up // clean up
weyl_destroy_bruhat(dq); weyl_destroy_bruhat(dq);
free(color);
free(type.factors); free(type.factors);
} }