/* 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); }
/* twopi_layout: */ void twopi_layout(Agraph_t * g) { Agnode_t *ctr = 0; char *s; int setRoot = 0; pointf sc; int doScale = 0; int r; if (agnnodes(g) == 0) return; twopi_init_graph(g); s = agget(g, "root"); if ((s = agget(g, "root"))) { if (*s) { 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"); setRoot = 1; } } else { setRoot = 1; } } if ((s = agget(g, "scale")) && *s) { if ((r = sscanf (s, "%lf,%lf",&sc.x,&sc.y))) { if (r == 1) sc.y = sc.x; doScale = 1; if (Verbose) fprintf (stderr, "scale = (%f,%f)\n", sc.x, sc.y); } } if (agnnodes(g)) { Agraph_t **ccs; Agraph_t *sg; Agnode_t *c = NULL; Agnode_t *n; int ncc; int i; ccs = ccomps(g, &ncc, 0); if (ncc == 1) { c = circleLayout(g, ctr); if (setRoot && !ctr) ctr = c; n = agfstnode(g); free(ND_alg(n)); ND_alg(n) = NULL; if (doScale) scaleGraph (g, c, sc); adjustNodes(g); spline_edges(g); } else { pack_info pinfo; getPackInfo (g, l_node, CL_OFFSET, &pinfo); pinfo.doSplines = 0; for (i = 0; i < ncc; i++) { sg = ccs[i]; if (ctr && agcontains(sg, ctr)) c = ctr; else c = 0; nodeInduce(sg); c = circleLayout(sg, c); if (setRoot && !ctr) ctr = c; if (doScale) scaleGraph (sg, c, sc); adjustNodes(sg); } n = agfstnode(g); free(ND_alg(n)); ND_alg(n) = NULL; packSubgraphs(ncc, ccs, g, &pinfo); spline_edges(g); } for (i = 0; i < ncc; i++) { agdelete(g, ccs[i]); } free(ccs); } if (setRoot) agset (g, "root", agnameof (ctr)); dotneato_postprocess(g); }
void sfdp_layout(graph_t * g) { int doAdjust; adjust_data am; int hops = -1; sfdp_init_graph(g); doAdjust = (Ndim == 2); if (agnnodes(g)) { Agraph_t **ccs; Agraph_t *sg; int ncc; int i; expand_t sep; pointf pad; spring_electrical_control ctrl = spring_electrical_control_new(); tuneControl (g, ctrl); #if (HAVE_GTS || HAVE_TRIANGLE) graphAdjustMode(g, &am, "prism0"); #else graphAdjustMode(g, &am, 0); #endif if ((am.mode == AM_PRISM) && doAdjust) { doAdjust = 0; /* overlap removal done in sfpd */ ctrl->overlap = am.value; ctrl->initial_scaling = am.scaling; sep = sepFactor(g); if (sep.doAdd) { pad.x = PS2INCH(sep.x); pad.y = PS2INCH(sep.y); } else { pad.x = PS2INCH(DFLT_MARGIN); pad.y = PS2INCH(DFLT_MARGIN); } } else { /* Turn off overlap removal in sfdp if prism not used */ ctrl->overlap = -1; } ccs = ccomps(g, &ncc, 0); if (ncc == 1) { sfdpLayout(g, ctrl, hops, pad); if (doAdjust) removeOverlapWith(g, &am); spline_edges(g); } else { pack_info pinfo; getPackInfo(g, l_node, CL_OFFSET, &pinfo); pinfo.doSplines = 1; for (i = 0; i < ncc; i++) { sg = ccs[i]; nodeInduce(sg); sfdpLayout(sg, ctrl, hops, pad); if (doAdjust) removeOverlapWith(sg, &am); setEdgeType(sg, ET_LINE); spline_edges(sg); } packSubgraphs(ncc, ccs, g, &pinfo); } for (i = 0; i < ncc; i++) { agdelete(g, ccs[i]); } free(ccs); spring_electrical_control_delete(ctrl); } dotneato_postprocess(g); }