]> granicus.if.org Git - graphviz/commitdiff
Fix "trouble in init_rank" when graph has a disconnected node
authornorth <devnull@localhost>
Thu, 26 Jan 2006 14:19:51 +0000 (14:19 +0000)
committernorth <devnull@localhost>
Thu, 26 Jan 2006 14:19:51 +0000 (14:19 +0000)
with rank=max or rank=sink.  b7.dot still dumps core.

lib/dotgen/position.c
lib/dotgen/rank.c

index 71cc5c5ba60525e92d444e043a6d471f143eef28..67e40ca484db3a315fe9ef0de57585237fc61c87 100644 (file)
@@ -73,7 +73,7 @@ connectGraph (graph_t* g)
     edge_t* e;
     rank_t* rp;
 
-    for (r = GD_minrank(g); r < GD_maxrank(g); r++) {
+    for (r = GD_minrank(g); r <= GD_maxrank(g); r++) {
        rp = GD_rank(g)+r;
        found =FALSE;
         tp = NULL;
@@ -100,7 +100,8 @@ connectGraph (graph_t* g)
        }
        if (found || !tp) continue;
        tp = rp->v[0];
-       hp = (rp+1)->v[0];
+       if (r < GD_maxrank(g)) hp = (rp+1)->v[0];
+       else hp = (rp-1)->v[0];
        assert (hp);
        sn = virtual_node(g);
        ND_node_type(sn) = SLACKNODE;
index e4e50e1ad471919259bf8c3c3383a1c919596a2c..bae2ac50d5ae1aaee5901b5190ea6a96771d1aeb 100644 (file)
@@ -465,6 +465,7 @@ void dot_rank(graph_t * g)
     decompose(g, 0);
     acyclic(g);
     minmax_edges2(g, p);
+    decompose(g, 0);
 #ifdef ALLOW_LEVELS
     if ((N_level = agfindattr(g->proto->n, "level")))
        setRanks(g, N_level);