new transitive reduction algo

This commit is contained in:
Florian Stecker 2016-10-29 17:02:05 +02:00
parent 68bc766f92
commit 4703357f41
1 changed files with 10 additions and 7 deletions

View File

@ -224,31 +224,34 @@ void prepare_graph(semisimple_type_t type, node_t *graph, edgelist_t **edgelists
for(int i = 0; i < order; i++) {
memset(seen, 0, order*sizeof(int));
for(int len = 1; len <= max_wordlength; len++) {
queue_init(&queue);
for(int len = 1; len <= graph[i].wordlength; len++) {
// remove all edges originating from i of length len which connect to something already seen using shorter edges
edge = graph[i].bruhat_lower;
previous = (edgelist_t*)0;
while(edge) {
if(seen[edge->to] && graph[i].wordlength - graph[edge->to].wordlength == len) {
// fprintf(stderr, "deleting from %d to %d\n", i, edge->to);
if(graph[i].wordlength - graph[edge->to].wordlength != len) {
previous = edge;
} else if(seen[edge->to]) {
if(previous)
previous->next = edge->next;
else
graph[i].bruhat_lower = edge->next;
} else {
previous = edge;
seen[edge->to] = 1;
queue_put(&queue, edge->to);
}
edge = edge->next;
}
// see which nodes we can reach using only edges up to length len, mark them as seen
queue_init(&queue);
queue_put(&queue, i);
seen[i] = 1;
while((current = queue_get(&queue)) != -1) {
edge = graph[current].bruhat_lower;
while(edge) {
if(!seen[edge->to] && graph[current].wordlength - graph[edge->to].wordlength == len) {
if(!seen[edge->to]) {
seen[edge->to] = 1;
queue_put(&queue, edge->to);
}