/* doDot: * Assume g has nodes. */ static void doDot (Agraph_t* g) { Agraph_t **ccs; Agraph_t *sg; int ncc; int i; pack_info pinfo; int Pack = getPack(g, -1, CL_OFFSET); pack_mode mode = getPackModeInfo (g, l_undef, &pinfo); getPackInfo(g, l_node, CL_OFFSET, &pinfo); if ((mode == l_undef) && (Pack < 0)) { /* No pack information; use old dot with components * handled during layout */ dotLayout(g); } else { /* fill in default values */ if (mode == l_undef) pinfo.mode = l_node; else if (Pack < 0) Pack = CL_OFFSET; pinfo.margin = Pack; pinfo.fixed = 0; /* components using clusters */ ccs = cccomps(g, &ncc, 0); if (ncc == 1) { dotLayout(g); } else if (GD_drawing(g)->ratio_kind == R_NONE) { pinfo.doSplines = 1; for (i = 0; i < ncc; i++) { sg = ccs[i]; initSubg (sg, g); dotLayout (sg); } attachPos (g); packSubgraphs(ncc, ccs, g, &pinfo); resetCoord (g); } else { /* Not sure what semantics should be for non-trivial ratio * attribute with multiple components. * One possibility is to layout nodes, pack, then apply the ratio * adjustment. We would then have to re-adjust all positions. */ dotLayout(g); } for (i = 0; i < ncc; i++) { free (GD_drawing(ccs[i])); agdelete(g, ccs[i]); } free(ccs); } }
/* twopi_layout: */ void twopi_layout(Agraph_t * g) { Agnode_t *ctr = 0; char *s; twopi_init_graph(g); s = agget(g, "root"); if (s && (*s != '\0')) { ctr = agfindnode(g, s); if (!ctr) { agerr(AGWARN, "specified root node \"%s\" was not found.", s); agerr(AGPREV, "Using default calculation for root node\n"); } } if (agnnodes(g)) { Agraph_t **ccs; Agraph_t *sg; Agnode_t *c = NULL; int ncc; int i; ccs = ccomps(g, &ncc, 0); if (ncc == 1) { circleLayout(g, ctr); adjustNodes(g); spline_edges(g); } else { pack_info pinfo; pack_mode pmode = getPackMode(g, l_node); for (i = 0; i < ncc; i++) { sg = ccs[i]; if (ctr && agcontains(sg, ctr)) c = ctr; else c = 0; nodeInduce(sg); circleLayout(sg, c); adjustNodes(sg); } spline_edges(g); pinfo.margin = getPack(g, CL_OFFSET, CL_OFFSET); pinfo.doSplines = 1; pinfo.mode = pmode; pinfo.fixed = 0; packSubgraphs(ncc, ccs, g, &pinfo); } for (i = 0; i < ncc; i++) { agdelete(g, ccs[i]); } free(ccs); } dotneato_postprocess(g); }