From: erg Date: Fri, 24 Jun 2005 18:26:46 +0000 (+0000) Subject: Add experimental, non-default code for allowing the graph to specify X-Git-Tag: LAST_LIBGRAPH~32^2~7498 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b9e61b43a8217a41a4267f7a6cc9efe1e333d748;p=graphviz Add experimental, non-default code for allowing the graph to specify the ranking. --- diff --git a/lib/dotgen/rank.c b/lib/dotgen/rank.c index 495643bff..18f998e91 100644 --- a/lib/dotgen/rank.c +++ b/lib/dotgen/rank.c @@ -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);