64 #define NEW_EDGE(e) (ED_to_virt(e) == 0)
88 int isRoot = (rg == infop->
rootg);
101 while ((cg = *cp++)) {
136 if (isRoot || isEmpty)
140 pt.
x = -bb.
LL.
x + margin;
144 bb.
UR.
x += pt.
x + margin;
151 while ((cg = *cp++)) {
196 static void freeDeriveNode(
node_t * n)
203 static void freeGData(
graph_t * g)
215 while ((cg = *cc++)) {
274 evalPositions(subg, rootg);
286 static void initCList(
clist_t * clist)
302 if (clist->
cnt >= clist->
sz) {
306 clist->
cl[clist->
cnt] = subg;
319 static char *portName(
graph_t * g, bport_t * p)
324 static char buf[
BSZ + 1];
356 if (g != infop->
rootg) {
358 pp =
agxget(parent, G_coord);
359 if ((pp == p) || !strcmp(p, pp))
363 if (sscanf(p,
"%lf,%lf,%lf,%lf%c",
379 agerr(
AGWARN,
"graph %s, coord %s, expected four doubles\n",
437 sprintf(name,
"_dg_%d", infop->
gid++);
439 fprintf(stderr,
"derive graph %s of %s\n", name,
agnameof(g));
451 copyAttr(g,dg,
"overlap");
452 copyAttr(g,dg,
"sep");
461 dn = mkDeriveNode(dg,
agnameof(subg));
465 chkPos(subg, dn, infop, &fix_bb);
546 if ((pp = PORTS(g))) {
552 PORTS(dg) = pq =
N_NEW(sz + 1, bport_t);
558 dn = mkDeriveNode(dg, portName(g, pp));
574 pq->alpha = pp->alpha;
589 static int ecmp(
const void *v1,
const void *v2)
605 #define ANG (M_PI/90)
632 erecs[i].
alpha = atan2(dy, dx);
633 erecs[i].
dist2 = dx * dx + dy * dy;
637 qsort(erecs, deg,
sizeof(
erec), ecmp);
642 double a, inc, delta, bnd;
645 while (i < deg - 1) {
648 while ((j < deg) && (erecs[j].
alpha == a))
656 bnd = erecs[j].
alpha;
657 delta = (bnd - a) / (j - i);
662 erecs[i].
alpha += inc;
681 genPorts(
node_t * n,
erec * er, bport_t * pp,
int idx,
double bnd)
698 delta = (bnd - er->
alpha) / cnt;
709 angle += delta * (cnt - 1);
714 for (j = 0; j <
ED_count(e); j++, ep++) {
745 pp =
N_NEW(sz + 1, bport_t);
748 es = ep = getEdgeList(n, cg);
757 idx = genPorts(n, ep, pp, idx, bnd);
821 vertices[1].
x = -
ND_lw(n);
823 vertices[2].
x = -
ND_lw(n);
879 fprintf (stderr,
"layout %s\n",
agnameof(g));
885 dg = deriveGraph(g, infop);
886 cc = pg =
findCComp(dg, &c_cnt, &pinned);
888 while ((cg = *pg++)) {
891 for (n =
agfstnode(cg); n; n = nxtnode) {
895 sg = expandCluster(n, cg);
904 }
else if (IS_PORT(n))
910 if (g == infop->
rootg)
931 bp =
N_NEW(c_cnt,
boolean);
946 finalCC(dg, c_cnt, cc, pts, g, infop);
956 BB(sg).UR.x = BB(sg).LL.x +
ND_width(dn);
957 BB(sg).UR.y = BB(sg).LL.y +
ND_height(dn);
958 }
else if ((n = ANODE(dn))) {
965 if (g == infop->
rootg)
970 freeDerivedGraph(dg, cc);
976 fprintf (stderr,
"end %s\n",
agnameof(g));
1029 if (pclist ==
NULL) {
1038 if (!strncmp(
agnameof(subg),
"cluster", 7)) {
1042 LEVEL(subg) = LEVEL(parent) + 1;
1044 addCluster(clist, subg);
1045 mkClusters(subg,
NULL, subg);
1048 mkClusters(subg, clist, parent);
1051 if (pclist ==
NULL) {
1058 static void fdp_init_graph(
Agraph_t * g)
1065 mkClusters (g,
NULL, g);
1070 static void fdpLayout(
graph_t * g)
1074 init_info(g, &info);
1102 "splines and cluster edges not supported - using line segments\n");
graph_t ** findCComp(graph_t *g, int *cnt, int *pinned)
CGRAPH_API Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
#define RALLOC(size, ptr, type)
CGRAPH_API Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
#define DEFAULT_NODEWIDTH
Agsym_t * agattr(Agraph_t *g, int kind, char *name, char *value)
bool layout(Agraph_t *g, const char *engine)
int agxset(void *obj, Agsym_t *sym, char *value)
#define ALLOC(size, ptr, type)
#define DEFAULT_NODEHEIGHT
EXTERN Agsym_t * G_margin
void gv_postprocess(Agraph_t *g, int allowTranslation)
CGRAPH_API Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
CGRAPH_API int agdelete(Agraph_t *g, void *obj)
int agerr(agerrlevel_t level, const char *fmt,...)
CGRAPH_API Agraph_t * agfstsubg(Agraph_t *g)
int splineEdges(graph_t *, int(*edgefn)(graph_t *, expand_t *, int), int)
pack_mode getPackInfo(Agraph_t *g, pack_mode dflt, int dfltMargin, pack_info *pinfo)
CGRAPH_API Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
int compoundEdges(graph_t *g, expand_t *pm, int edgetype)
#define PS2INCH(a_points)
CGRAPH_API Agraph_t * agnxtsubg(Agraph_t *subg)
CGRAPH_API Agnode_t * agtail(Agedge_t *e)
CGRAPH_API Agdesc_t Agstrictdirected
int normalize(graph_t *g)
CGRAPH_API Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
CGRAPH_API Agnode_t * aghead(Agedge_t *e)
void fdp_layout(Agraph_t *g)
CGRAPH_API int agclose(Agraph_t *g)
CGRAPH_API char * agnameof(void *)
CGRAPH_API Agraph_t * agparent(Agraph_t *g)
#define INCH2PS(a_inches)
void fdp_initParams(graph_t *g)
void compute_bb(graph_t *g)
CGRAPH_API Agnode_t * agfstnode(Agraph_t *g)
int late_int(void *obj, attrsym_t *attr, int def, int low)
double get_inputscale(graph_t *g)
void fdp_xLayout(graph_t *g, xparams *xpms)
real cg(Operator Ax, Operator precond, int n, int dim, real *x0, real *rhs, real tol, int maxit, int *flag)
CGRAPH_API Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
CGRAPH_API int agdelrec(void *obj, char *name)
EXTERN unsigned char Verbose
CGRAPH_API int agnnodes(Agraph_t *g)
CGRAPH_API Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
void fdp_tLayout(graph_t *g, xparams *xpms)
CGRAPH_API void * agbindrec(void *obj, char *name, unsigned int size, int move_to_front)
void setEdgeType(graph_t *g, int dflt)
#define HAS_CLUST_EDGE(g)
point * putGraphs(int ng, Agraph_t **gs, Agraph_t *root, pack_info *pinfo)
int spline_edges1(graph_t *g, int)
EXTERN double PSinputscale
char * agxget(void *obj, Agsym_t *sym)
CGRAPH_API Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
void fdp_init_node_edge(Agraph_t *g)
char * el(GVJ_t *job, char *template,...)
boolean neato_set_aspect(graph_t *g)