2018-03-28 10:43:23 +02:00
|
|
|
#include "queue.h"
|
2025-03-08 11:56:27 -05:00
|
|
|
#include "weyl.h"
|
2018-03-28 10:43:23 +02:00
|
|
|
|
|
|
|
#include <memory.h>
|
2025-03-08 11:56:27 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <strings.h>
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
static char *alphabetize(weylgroup_element_t *e, char *str) {
|
|
|
|
if (e->wordlength == 0)
|
2018-03-28 10:43:23 +02:00
|
|
|
sprintf(str, "1");
|
|
|
|
else {
|
2025-03-08 11:56:27 -05:00
|
|
|
for (int j = 0; j < e->wordlength; j++)
|
2018-03-28 10:43:23 +02:00
|
|
|
str[j] = e->word[j] + 'a';
|
|
|
|
str[e->wordlength] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
semisimple_type_t type;
|
|
|
|
unsigned long right_invariance, left_invariance;
|
|
|
|
doublequotient_t *dq;
|
|
|
|
const char *alphabet = "abcdefghijklmnopqrstuvwxyz";
|
|
|
|
char stringbuffer[100];
|
|
|
|
char stringbuffer2[100];
|
|
|
|
|
|
|
|
ERROR(argc < 2, "Too few arguments!\n");
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
type.n = 0;
|
|
|
|
for (int i = 0; i < argc - 1; i++) {
|
|
|
|
if (argv[i + 1][0] < 'A' || argv[i + 1][0] > 'G')
|
|
|
|
break;
|
|
|
|
type.n++;
|
|
|
|
}
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
type.factors = (simple_type_t *)malloc(type.n * sizeof(simple_type_t));
|
|
|
|
for (int i = 0; i < type.n; i++) {
|
|
|
|
type.factors[i].series = argv[i + 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");
|
|
|
|
}
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
left_invariance = right_invariance = 0;
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
if (argc - type.n >= 3) {
|
|
|
|
if (strcmp(argv[type.n + 1], "-") != 0)
|
|
|
|
for (int i = 0; i < strlen(argv[type.n + 1]); i++)
|
|
|
|
left_invariance |= (1 << (argv[type.n + 1][i] - 'a'));
|
|
|
|
if (strcmp(argv[type.n + 2], "-") != 0)
|
|
|
|
for (int i = 0; i < strlen(argv[type.n + 2]); i++)
|
|
|
|
right_invariance |= (1 << (argv[type.n + 2][i] - 'a'));
|
|
|
|
}
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
// generate graph
|
|
|
|
dq = weyl_generate_bruhat(type, left_invariance, right_invariance);
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
// color ideals
|
|
|
|
int *color = (int*) malloc(dq->count * sizeof(int));
|
|
|
|
memset(color, 0, dq->count * sizeof(int));
|
|
|
|
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;
|
|
|
|
}
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
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),
|
|
|
|
color[i] > 0 ? "red" : "black");
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
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");
|
2018-03-28 10:43:23 +02:00
|
|
|
|
2025-03-08 11:56:27 -05:00
|
|
|
// clean up
|
|
|
|
weyl_destroy_bruhat(dq);
|
|
|
|
free(color);
|
|
|
|
free(type.factors);
|
2018-03-28 10:43:23 +02:00
|
|
|
}
|