From: Emden Gansner Date: Tue, 7 Aug 2012 15:01:30 +0000 (-0400) Subject: Support one-block version of circo X-Git-Tag: LAST_LIBGRAPH~32^2~358^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a7be4e6093d8c43a48aee4aa19f3fe5af8538ef;p=graphviz Support one-block version of circo --- diff --git a/lib/circogen/circular.c b/lib/circogen/circular.c index 9a27fbfa0..68758a0ed 100644 --- a/lib/circogen/circular.c +++ b/lib/circogen/circular.c @@ -72,6 +72,34 @@ static void cleanup(block_t * root, circ_state * sp) freeBlocktree(root); } +static block_t* +createOneBlock(Agraph_t * g, circ_state * state) +{ + Agraph_t *subg; + char name[SMALLBUF]; + block_t *bp; + Agnode_t* n; + + sprintf(name, "_block_%d", state->blockCount++); +#ifdef WITH_CGRAPH + subg = agsubg(g, name, 1); +#else + subg = agsubg(g, name); +#endif + bp = mkBlock(subg); + + for (n = agfstnode(g); n; n = agnxtnode(g,n)) { +#ifdef WITH_CGRAPH + agsubnode(bp->sub_graph, n, 1); +#else + aginsert(bp->sub_graph, n); +#endif + BLOCK(n) = bp; + } + + return bp; +} + /* circularLayout: * Do circular layout of g. * Assume g is strict. @@ -80,7 +108,7 @@ static void cleanup(block_t * root, circ_state * sp) * We make state static so that it keeps a record of block numbers used * in a graph; it gets reset when a new root graph is used. */ -void circularLayout(Agraph_t * g) +void circularLayout(Agraph_t * g, Agraph_t* realg) { block_t *root; static circ_state state; @@ -94,7 +122,10 @@ void circularLayout(Agraph_t * g) initGraphAttrs(g, &state); - root = createBlocktree(g, &state); + if (mapbool(agget(realg, "oneblock"))) + root = createOneBlock(g, &state); + else + root = createBlocktree(g, &state); circPos(g, root, &state); cleanup(root, &state); diff --git a/lib/circogen/circular.h b/lib/circogen/circular.h index 91fc87198..f5c02423c 100644 --- a/lib/circogen/circular.h +++ b/lib/circogen/circular.h @@ -134,7 +134,7 @@ extern "C" { extern void prData(Agnode_t * n, int pass); #endif - extern void circularLayout(Agraph_t * sg); + extern void circularLayout(Agraph_t * sg, Agraph_t* rg); #ifdef __cplusplus } diff --git a/lib/circogen/circularinit.c b/lib/circogen/circularinit.c index a87ce9bcd..480347299 100644 --- a/lib/circogen/circularinit.c +++ b/lib/circogen/circularinit.c @@ -232,7 +232,7 @@ void circoLayout(Agraph_t * g) ccs = circomps(g, &ncc); if (ncc == 1) { - circularLayout(ccs[0]); + circularLayout(ccs[0], g); copyPosns(ccs[0]); adjustNodes(g); } else { @@ -242,7 +242,7 @@ void circoLayout(Agraph_t * g) for (i = 0; i < ncc; i++) { sg = ccs[i]; - circularLayout(sg); + circularLayout(sg, g); adjustNodes(sg); } /* FIX: splines have not been calculated for dg