chiark / gitweb /
elimtrivial finished we think
authorian <ian>
Sun, 13 Mar 2005 20:02:24 +0000 (20:02 +0000)
committerian <ian>
Sun, 13 Mar 2005 20:02:24 +0000 (20:02 +0000)
layout/redactgraph.c

index 05acebfe79e351a44738ad4f4b2a23ac3f501f6b..d24bf1be568f3b2a55d7f9e6258b09db66695dea 100644 (file)
@@ -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");
+  }
+}