]> granicus.if.org Git - graphviz/commitdiff
Add experimental, non-default code for allowing the graph to specify
authorerg <devnull@localhost>
Fri, 24 Jun 2005 18:26:46 +0000 (18:26 +0000)
committererg <devnull@localhost>
Fri, 24 Jun 2005 18:26:46 +0000 (18:26 +0000)
the ranking.

lib/dotgen/rank.c

index 495643bffb815806de62b160b7e33f6fb060a148..18f998e91360a49e53e8afe6ee5fdb2936e215b4 100644 (file)
@@ -424,8 +424,30 @@ void expand_ranksets(graph_t * g)
     }
 }
 
+#ifdef ALLOW_LEVELS
+void
+setRanks (graph_t* g, attrsym_t* lsym)
+{
+    node_t* n;
+    char*   s;
+    char*   ep;
+    long    v;
+
+    for (n = agfstnode(g); n; n = agnxtnode(g,n)) {
+       s = agxget (n, lsym->index);
+       v = strtol (s, &ep, 10);
+       if (ep == s)
+           agerr(AGWARN, "no level attribute for node \"%s\"\n", n->name);
+       ND_rank(n) = v;
+    }
+}
+#endif
+
 void dot_rank(graph_t * g)
 {
+#ifdef ALLOW_LEVELS
+    attrsym_t* N_level;
+#endif
     edgelabel_ranks(g);
     collapse_sets(g);
     /*collapse_leaves(g); */
@@ -433,6 +455,11 @@ void dot_rank(graph_t * g)
     minmax_edges(g);
     decompose(g, 0);
     acyclic(g);
+#ifdef ALLOW_LEVELS
+    if ((N_level = agfindattr(g->proto->n, "level")))
+       setRanks(g, N_level);
+    else
+#endif
     rank1(g);
     expand_ranksets(g);
     cleanup1(g);