new transitive reduction algo
This commit is contained in:
parent
68bc766f92
commit
4703357f41
@ -224,31 +224,34 @@ void prepare_graph(semisimple_type_t type, node_t *graph, edgelist_t **edgelists
|
|||||||
|
|
||||||
for(int i = 0; i < order; i++) {
|
for(int i = 0; i < order; i++) {
|
||||||
memset(seen, 0, order*sizeof(int));
|
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
|
// remove all edges originating from i of length len which connect to something already seen using shorter edges
|
||||||
edge = graph[i].bruhat_lower;
|
edge = graph[i].bruhat_lower;
|
||||||
previous = (edgelist_t*)0;
|
previous = (edgelist_t*)0;
|
||||||
|
|
||||||
while(edge) {
|
while(edge) {
|
||||||
if(seen[edge->to] && graph[i].wordlength - graph[edge->to].wordlength == len) {
|
if(graph[i].wordlength - graph[edge->to].wordlength != len) {
|
||||||
// fprintf(stderr, "deleting from %d to %d\n", i, edge->to);
|
previous = edge;
|
||||||
|
} else if(seen[edge->to]) {
|
||||||
if(previous)
|
if(previous)
|
||||||
previous->next = edge->next;
|
previous->next = edge->next;
|
||||||
else
|
else
|
||||||
graph[i].bruhat_lower = edge->next;
|
graph[i].bruhat_lower = edge->next;
|
||||||
} else {
|
} else {
|
||||||
previous = edge;
|
previous = edge;
|
||||||
|
seen[edge->to] = 1;
|
||||||
|
queue_put(&queue, edge->to);
|
||||||
}
|
}
|
||||||
edge = edge->next;
|
edge = edge->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
// see which nodes we can reach using only edges up to length len, mark them as seen
|
// 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) {
|
while((current = queue_get(&queue)) != -1) {
|
||||||
edge = graph[current].bruhat_lower;
|
edge = graph[current].bruhat_lower;
|
||||||
while(edge) {
|
while(edge) {
|
||||||
if(!seen[edge->to] && graph[current].wordlength - graph[edge->to].wordlength == len) {
|
if(!seen[edge->to]) {
|
||||||
seen[edge->to] = 1;
|
seen[edge->to] = 1;
|
||||||
queue_put(&queue, edge->to);
|
queue_put(&queue, edge->to);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user