From 0bb21d36f49797df3315ffa83413906f85f68cba Mon Sep 17 00:00:00 2001 From: ian Date: Sun, 13 Mar 2005 20:02:24 +0000 Subject: [PATCH] elimtrivial finished we think --- layout/redactgraph.c | 48 ++++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/layout/redactgraph.c b/layout/redactgraph.c index 05acebf..d24bf1b 100644 --- a/layout/redactgraph.c +++ b/layout/redactgraph.c @@ -39,12 +39,12 @@ static void extendsplits(void) { * the fixed portion and add its length to both the moveables, * so that we have one subsegspec for the whole of each position: * - * <---l---> <----l'----> <--------(l+l')------> + * <---l---> <----l'---> <---------(l+l')------> * * *----A1---*----A1/P0--* becomes *--------A1/P0----------* * `---A1/P1---* `-------A1/P1-----------* * - * <----l''---> <--------(l+l'')------> + * <----l''---> <---------(l+l'')------> */ for (;;) { @@ -108,18 +108,40 @@ static EdgeEnd *edgeend_otherend(EdgeEnd *thisend) { static void elimtrivial(void) { /* Eliminate trivial nodes: ones which have only two edges, which - * come in on opposite sides, have the same subsegspec. The two - * ends are supposed to be identically aligned. - - for $lk (@links) { - $nodeentries[$lk->[0]][$lk->[1]]++; - $nodeentries[$lk->[1]][$lk->[2]]++; + * come in on opposite sides, have the same subsegspec, and with the + * two ends identically aligned. + */ + for (node=nodes_head; node; node=next_node) { + next_node=node->next; + trace("elimtrivial node "); trace_node(node); trace(" "); + if (!(count_edges(&node->sides[0])==1 && + count_edges(&node->sides[1])==1)) { + trace("no, a non-unitary side\n"); + continue; } - for ($nodenum=0; $nodenum<@nodes; $nodenum++) { - -} -static void - + leftedge= node->sides[0].head; + rightedge= node->sides[0].head; + if (strcmp(leftedge->edge.segment,rightedge->edge.segment)) { + trace("no, segments differ\n"); + continue; + } + if (!!leftedge->edge.movfeatpos != !!rightedge->edge.movfeatpos || + strcmp(leftedge->edge.movfeatpos, rightedge->edge.movfeatpos)) { + trace("no, movfeatpos's differ\n"); + continue; + } + if (leftedge->end == rightedge->end) { + trace("no, opposite alignment\n"); + continue; + } + trace(" yes:\n"); + rightedge->edge->distance += leftedge->edge->distance; + edge_replumb(rightedge, edgeend_otherend(leftedge)->node); + edge_delete(leftedge->edge); + node_surely_orphaned(node); + trace(" elimtrivial operation complete\n"); + } +} -- 2.30.2