]> granicus.if.org Git - graphviz/commitdiff
Support one-block version of circo
authorEmden Gansner <erg@research.att.com>
Tue, 7 Aug 2012 15:01:30 +0000 (11:01 -0400)
committerEmden Gansner <erg@research.att.com>
Tue, 7 Aug 2012 15:01:30 +0000 (11:01 -0400)
lib/circogen/circular.c
lib/circogen/circular.h
lib/circogen/circularinit.c

index 9a27fbfa022e9da1797bea910b0ba10bec1a8cbe..68758a0ed71000b607960645aa522b803ebd3d19 100644 (file)
@@ -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);
index 91fc87198e7bebe88885667716924b32530277e1..f5c02423c04d00437a1f1b9f664cd109758e74ab 100644 (file)
@@ -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
 }
index a87ce9bcd340c4603410169a432ca9df5d7ce252..4803472993c1ca679cf6142de1e69328ce247290 100644 (file)
@@ -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