static void adjustregularpath(path *, int, int);
static Agedge_t *bot_bound(Agedge_t *, int);
static boolean pathscross(Agnode_t *, Agnode_t *, Agedge_t *, Agedge_t *);
-static Agraph_t *cl_bound(Agnode_t *, Agnode_t *);
+static Agraph_t *cl_bound(graph_t*, Agnode_t *, Agnode_t *);
static int cl_vninside(Agraph_t *, Agnode_t *);
static void completeregularpath(path *, Agedge_t *, Agedge_t *,
pathend_t *, pathend_t *, boxf *, int, int);
static int edgecmp(Agedge_t **, Agedge_t **);
-static void make_flat_edge(spline_info_t*, path *, Agedge_t **, int, int, int);
-static void make_regular_edge(spline_info_t*, path *, Agedge_t **, int, int, int);
+static void make_flat_edge(graph_t*, spline_info_t*, path *, Agedge_t **, int, int, int);
+static void make_regular_edge(graph_t* g, spline_info_t*, path *, Agedge_t **, int, int, int);
static boxf makeregularend(boxf, int, double);
-static boxf maximal_bbox(spline_info_t*, Agnode_t *, Agedge_t *, Agedge_t *);
-static Agnode_t *neighbor(Agnode_t *, Agedge_t *, Agedge_t *, int);
+static boxf maximal_bbox(graph_t* g, spline_info_t*, Agnode_t *, Agedge_t *, Agedge_t *);
+static Agnode_t *neighbor(graph_t*, Agnode_t *, Agedge_t *, Agedge_t *, int);
static void place_vnlabel(Agnode_t *);
static boxf rank_box(spline_info_t* sp, Agraph_t *, int);
static void recover_slack(Agedge_t *, path *);
}
}
else if (ND_rank(agtail(e0)) == ND_rank(aghead(e0))) {
- make_flat_edge(&sd, P, edges, ind, cnt, et);
+ make_flat_edge(g, &sd, P, edges, ind, cnt, et);
}
else
- make_regular_edge(&sd, P, edges, ind, cnt, et);
+ make_regular_edge(g, &sd, P, edges, ind, cnt, et);
}
/* place regular edge labels */
* more straightforward and laborious fashion.
*/
static void
-make_flat_adj_edges(path* P, edge_t** edges, int ind, int cnt, edge_t* e0,
+make_flat_adj_edges(graph_t* g, path* P, edge_t** edges, int ind, int cnt, edge_t* e0,
int et)
{
node_t* n;
node_t *tn, *hn;
edge_t* e;
int labels = 0, ports = 0;
- graph_t* g;
graph_t* auxg;
graph_t* subg;
node_t *auxt, *auxh;
edge_t* hvye = NULL;
attr_state_t* attrs;
- g = agraphof(agtail(e0));
tn = agtail(e0), hn = aghead(e0);
for (i = 0; i < cnt; i++) {
e = edges[ind + i];
/* makeFlatEnd;
*/
static void
-makeFlatEnd (spline_info_t* sp, path* P, node_t* n, edge_t* e, pathend_t* endp,
+makeFlatEnd (graph_t* g, spline_info_t* sp, path* P, node_t* n, edge_t* e, pathend_t* endp,
boolean isBegin)
{
boxf b;
- graph_t* g = agraphof(n);
- b = endp->nb = maximal_bbox(sp, n, NULL, e);
+ b = endp->nb = maximal_bbox(g, sp, n, NULL, e);
endp->sidemask = TOP;
if (isBegin) beginpath(P, e, FLATEDGE, endp, FALSE);
else endpath(P, e, FLATEDGE, endp, FALSE);
/* makeBottomFlatEnd;
*/
static void
-makeBottomFlatEnd (spline_info_t* sp, path* P, node_t* n, edge_t* e,
+makeBottomFlatEnd (graph_t* g, spline_info_t* sp, path* P, node_t* n, edge_t* e,
pathend_t* endp, boolean isBegin)
{
boxf b;
- graph_t* g = agraphof(n);
- b = endp->nb = maximal_bbox(sp, n, NULL, e);
+ b = endp->nb = maximal_bbox(g, sp, n, NULL, e);
endp->sidemask = BOTTOM;
if (isBegin) beginpath(P, e, FLATEDGE, endp, FALSE);
else endpath(P, e, FLATEDGE, endp, FALSE);
/* make_flat_labeled_edge:
*/
static void
-make_flat_labeled_edge(spline_info_t* sp, path* P, edge_t* e, int et)
+make_flat_labeled_edge(graph_t* g, spline_info_t* sp, path* P, edge_t* e, int et)
{
- graph_t *g;
node_t *tn, *hn, *ln;
pointf *ps;
pathend_t tend, hend;
tn = agtail(e);
hn = aghead(e);
- g = agraphof(tn);
for (f = ED_to_virt(e); ED_to_virt(f); f = ED_to_virt(f));
ln = agtail(f);
lb.LL.y = lb.UR.y - MAX(5.,ydelta);
boxn = 0;
- makeFlatEnd (sp, P, tn, e, &tend, TRUE);
- makeFlatEnd (sp, P, hn, e, &hend, FALSE);
+ makeFlatEnd (g, sp, P, tn, e, &tend, TRUE);
+ makeFlatEnd (g, sp, P, hn, e, &hend, FALSE);
boxes[boxn].LL.x = tend.boxes[tend.boxn - 1].LL.x;
boxes[boxn].LL.y = tend.boxes[tend.boxn - 1].UR.y;
/* make_flat_bottom_edges:
*/
static void
-make_flat_bottom_edges(spline_info_t* sp, path * P, edge_t ** edges, int
+make_flat_bottom_edges(graph_t* g, spline_info_t* sp, path * P, edge_t ** edges, int
ind, int cnt, edge_t* e, int splines)
{
node_t *tn, *hn;
int pn;
pointf *ps;
pathend_t tend, hend;
- graph_t* g;
tn = agtail(e);
hn = aghead(e);
- g = agraphof(tn);
r = ND_rank(tn);
if (r < GD_maxrank(g)) {
nextr = GD_rank(g) + (r+1);
stepx = ((double)(sp->Multisep)) / (cnt+1);
stepy = vspace / (cnt+1);
- makeBottomFlatEnd (sp, P, tn, e, &tend, TRUE);
- makeBottomFlatEnd (sp, P, hn, e, &hend, FALSE);
+ makeBottomFlatEnd (g, sp, P, tn, e, &tend, TRUE);
+ makeBottomFlatEnd (g, sp, P, hn, e, &hend, FALSE);
for (i = 0; i < cnt; i++) {
int boxn;
* = the rest - route along top
*/
static void
-make_flat_edge(spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt, int et)
+make_flat_edge(graph_t* g, spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt, int et)
{
node_t *tn, *hn;
Agedgeinfo_t fwdedgei;
int tside, hside, pn;
pointf *ps;
pathend_t tend, hend;
- graph_t* g;
fwdedge.out.base.data = (Agrec_t*)&fwdedgei;
* so check them all.
*/
if (isAdjacent) {
- make_flat_adj_edges (P, edges, ind, cnt, e, et);
+ make_flat_adj_edges (g, P, edges, ind, cnt, e, et);
return;
}
if (ED_label(e)) { /* edges with labels aren't multi-edges */
- make_flat_labeled_edge (sp, P, e, et);
+ make_flat_labeled_edge (g, sp, P, e, et);
return;
}
hside = ED_head_port(e).side;
if (((tside == BOTTOM) && (hside != TOP)) ||
((hside == BOTTOM) && (tside != TOP))) {
- make_flat_bottom_edges (sp, P, edges, ind, cnt, e, et == ET_SPLINE);
+ make_flat_bottom_edges (g, sp, P, edges, ind, cnt, e, et == ET_SPLINE);
return;
}
tn = agtail(e);
hn = aghead(e);
- g = agraphof(tn);
r = ND_rank(tn);
if (r > 0) {
rank_t* prevr;
stepx = ((double)sp->Multisep) / (cnt+1);
stepy = vspace / (cnt+1);
- makeFlatEnd (sp, P, tn, e, &tend, TRUE);
- makeFlatEnd (sp, P, hn, e, &hend, FALSE);
+ makeFlatEnd (g, sp, P, tn, e, &tend, TRUE);
+ makeFlatEnd (g, sp, P, hn, e, &hend, FALSE);
for (i = 0; i < cnt; i++) {
int boxn;
* multiple edges better.
*/
static int
-makeLineEdge(edge_t* fe, pointf* points, node_t** hp)
+makeLineEdge(graph_t* g, edge_t* fe, pointf* points, node_t** hp)
{
int delr, pn;
node_t* hn;
hn = aghead(e);
tn = agtail(e);
delr = ABS(ND_rank(hn)-ND_rank(tn));
- if ((delr == 1) || ((delr == 2) && (GD_has_labels(agraphof(hn)) & EDGE_LABEL)))
+ if ((delr == 1) || ((delr == 2) && (GD_has_labels(g) & EDGE_LABEL)))
return 0;
if (agtail(fe) == agtail(e)) {
*hp = hn;
/* make_regular_edge:
*/
static void
-make_regular_edge(spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt, int et)
+make_regular_edge(graph_t* g, spline_info_t* sp, path * P, edge_t ** edges, int ind, int cnt, int et)
{
- graph_t *g;
node_t *tn, *hn;
Agedgeinfo_t fwdedgeai, fwdedgebi, fwdedgei;
Agedgepair_t fwdedgea, fwdedgeb, fwdedge;
}
sl = 0;
e = edges[ind];
- g = agraphof(agtail(e));
hackflag = FALSE;
if (ABS(ND_rank(agtail(e)) - ND_rank(aghead(e))) > 1) {
fwdedgeai = *(Agedgeinfo_t*)e->base.data;
/* compute the spline points for the edge */
- if ((et == ET_LINE) && (pointn = makeLineEdge (fe, pointfs, &hn))) {
+ if ((et == ET_LINE) && (pointn = makeLineEdge (g, fe, pointfs, &hn))) {
}
else {
int splines = et == ET_SPLINE;
segfirst = e;
tn = agtail(e);
hn = aghead(e);
- b = tend.nb = maximal_bbox(sp, tn, NULL, e);
+ b = tend.nb = maximal_bbox(g, sp, tn, NULL, e);
beginpath(P, e, REGULAREDGE, &tend, spline_merge(tn));
b.UR.y = tend.boxes[tend.boxn - 1].UR.y;
b.LL.y = tend.boxes[tend.boxn - 1].LL.y;
b = makeregularend(b, BOTTOM,
- ND_coord(tn).y - GD_rank(agraphof(tn))[ND_rank(tn)].ht1);
+ ND_coord(tn).y - GD_rank(g)[ND_rank(tn)].ht1);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
tend.boxes[tend.boxn++] = b;
longedge = 0;
}
if (!smode || si > 0) {
si--;
- boxes[boxn++] = maximal_bbox(sp, hn, e, ND_out(hn).list[0]);
+ boxes[boxn++] = maximal_bbox(g, sp, hn, e, ND_out(hn).list[0]);
e = ND_out(hn).list[0];
tn = agtail(e);
hn = aghead(e);
continue;
}
- hend.nb = maximal_bbox(sp, hn, e, ND_out(hn).list[0]);
+ hend.nb = maximal_bbox(g, sp, hn, e, ND_out(hn).list[0]);
endpath(P, e, REGULAREDGE, &hend, spline_merge(aghead(e)));
b = makeregularend(hend.boxes[hend.boxn - 1], TOP,
- ND_coord(hn).y + GD_rank(agraphof(hn))[ND_rank(hn)].ht2);
+ ND_coord(hn).y + GD_rank(g)[ND_rank(hn)].ht2);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
hend.boxes[hend.boxn++] = b;
P->end.theta = M_PI / 2, P->end.constrained = TRUE;
tn = agtail(e);
hn = aghead(e);
boxn = 0;
- tend.nb = maximal_bbox(sp, tn, ND_in(tn).list[0], e);
+ tend.nb = maximal_bbox(g, sp, tn, ND_in(tn).list[0], e);
beginpath(P, e, REGULAREDGE, &tend, spline_merge(tn));
b = makeregularend(tend.boxes[tend.boxn - 1], BOTTOM,
- ND_coord(tn).y - GD_rank(agraphof(tn))[ND_rank(tn)].ht1);
+ ND_coord(tn).y - GD_rank(g)[ND_rank(tn)].ht1);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
tend.boxes[tend.boxn++] = b;
P->start.theta = -M_PI / 2, P->start.constrained = TRUE;
smode = FALSE;
}
boxes[boxn++] = rank_box(sp, g, ND_rank(tn));
- b = hend.nb = maximal_bbox(sp, hn, e, NULL);
+ b = hend.nb = maximal_bbox(g, sp, hn, e, NULL);
endpath(P, hackflag ? &fwdedgeb.out : e, REGULAREDGE, &hend, spline_merge(aghead(e)));
b.UR.y = hend.boxes[hend.boxn - 1].UR.y;
b.LL.y = hend.boxes[hend.boxn - 1].LL.y;
b = makeregularend(b, TOP,
- ND_coord(hn).y + GD_rank(agraphof(hn))[ND_rank(hn)].ht2);
+ ND_coord(hn).y + GD_rank(g)[ND_rank(hn)].ht2);
if (b.LL.x < b.UR.x && b.LL.y < b.UR.y)
hend.boxes[hend.boxn++] = b;
completeregularpath(P, segfirst, e, &tend, &hend, boxes, boxn,
* It is not clear this will handle all potential problems. It seems one
* could have hcl and tcl contained in cl, which would also cause problems.
*/
-#define REAL_CLUSTER(n) (ND_clust(n)==agraphof(n)?NULL:ND_clust(n))
+#define REAL_CLUSTER(n) (ND_clust(n)==g?NULL:ND_clust(n))
/* returns the cluster of (adj) that interferes with n,
*/
-static Agraph_t *cl_bound(n, adj)
-node_t *n, *adj;
+static Agraph_t *cl_bound(graph_t* g, node_t *n, node_t *adj)
{
graph_t *rv, *cl, *tcl, *hcl;
edge_t *orig;
*/
#define FUDGE 4
-static boxf maximal_bbox(spline_info_t* sp, node_t* vn, edge_t* ie, edge_t* oe)
+static boxf maximal_bbox(graph_t* g, spline_info_t* sp, node_t* vn, edge_t* ie, edge_t* oe)
{
double b, nb;
- graph_t *g = agraphof(vn), *left_cl, *right_cl;
+ graph_t *left_cl, *right_cl;
node_t *left, *right;
boxf rv;
/* give this node all the available space up to its neighbors */
b = (double)(ND_coord(vn).x - ND_lw(vn) - FUDGE);
- if ((left = neighbor(vn, ie, oe, -1))) {
- if ((left_cl = cl_bound(vn, left)))
+ if ((left = neighbor(g, vn, ie, oe, -1))) {
+ if ((left_cl = cl_bound(g, vn, left)))
nb = GD_bb(left_cl).UR.x + (double)(sp->Splinesep);
else {
nb = (double)(ND_coord(left).x + ND_mval(left));
b = (double)(ND_coord(vn).x + 10);
else
b = (double)(ND_coord(vn).x + ND_rw(vn) + FUDGE);
- if ((right = neighbor(vn, ie, oe, 1))) {
- if ((right_cl = cl_bound(vn, right)))
+ if ((right = neighbor(g, vn, ie, oe, 1))) {
+ if ((right_cl = cl_bound(g, vn, right)))
nb = GD_bb(right_cl).LL.x - (double)(sp->Splinesep);
else {
nb = ND_coord(right).x - ND_lw(right);
return rv;
}
-static node_t *neighbor(vn, ie, oe, dir)
-node_t *vn;
-edge_t *ie, *oe;
-int dir;
+static node_t *
+neighbor(graph_t* g, node_t *vn, edge_t *ie, edge_t *oe, int dir)
{
int i;
node_t *n, *rv = NULL;
- rank_t *rank = &(GD_rank(agraphof(vn))[ND_rank(vn)]);
+ rank_t *rank = &(GD_rank(g)[ND_rank(vn)]);
for (i = ND_order(vn) + dir; ((i >= 0) && (i < rank->n)); i += dir) {
n = rank->v[i];
if (m0 > USHRT_MAX)
m0 = largeMinlen (m0);
ED_minlen(e0) = MAX(ED_minlen(e0), m0);
+ ED_weight(e0) = MAX(ED_weight(e0), ED_weight(e));
}
else if (!ED_label(e)) {
/* unlabeled flat edge between non-neighbors
int c;
edge_t *e;
- if (g != agroot(g)) {
+ if (g != dot_root(g)) {
contain_nodes(g);
if ((e = find_fast_edge(GD_ln(g),GD_rn(g)))) /* maybe from lrvn()?*/
ED_weight(e) += 128;
if (v == NULL)
continue;
for (i = ND_order(v) - 1; i >= 0; i--) {
- u = GD_rank(agroot(g))[r].v[i];
+ u = GD_rank(dot_root(g))[r].v[i];
/* can't use "is_a_vnode_of" because elists are swapped */
if ((ND_node_type(u) == NORMAL) || vnode_not_related_to(g, u)) {
make_aux_edge(u, GD_ln(g), margin + ND_rw(u), 0);
break;
}
}
- for (i = ND_order(v) + GD_rank(g)[r].n; i < GD_rank(agroot(g))[r].n;
+ for (i = ND_order(v) + GD_rank(g)[r].n; i < GD_rank(dot_root(g))[r].n;
i++) {
- u = GD_rank(agroot(g))[r].v[i];
+ u = GD_rank(dot_root(g))[r].v[i];
if ((ND_node_type(u) == NORMAL) || vnode_not_related_to(g, u)) {
make_aux_edge(GD_rn(g), u, margin + ND_lw(u), 0);
break;
static void adjustSimple(graph_t * g, int delta, int margin_total)
{
int r, bottom, deltop, delbottom;
- graph_t *root = agroot(g);
+ graph_t *root = dot_root(g);
rank_t *rank = GD_rank(root);
int maxr = GD_maxrank(g);
int minr = GD_minrank(g);
int c;
double delta, ht1, ht2;
- rank_t *rank = GD_rank(agroot(g));
- if (g == agroot(g))
+ rank_t *rank = GD_rank(dot_root(g));
+ if (g == dot_root(g))
margin = 0;
else
margin = late_int (g, G_margin, CL_OFFSET, 0);
GD_ht1(g) = ht1;
GD_ht2(g) = ht2;
- if ((g != agroot(g)) && GD_label(g)) {
+ if ((g != dot_root(g)) && GD_label(g)) {
lht = MAX(GD_border(g)[LEFT_IX].y, GD_border(g)[RIGHT_IX].y);
maxr = GD_maxrank(g);
minr = GD_minrank(g);
}
/* update the global ranks */
- if (g != agroot(g)) {
+ if (g != dot_root(g)) {
rank[GD_minrank(g)].ht2 = MAX(rank[GD_minrank(g)].ht2, GD_ht2(g));
rank[GD_maxrank(g)].ht1 = MAX(rank[GD_maxrank(g)].ht1, GD_ht1(g));
}
int c;
double ht1, ht2;
graph_t *subg;
- rank_t *rank = GD_rank(agroot(g));
+ rank_t *rank = GD_rank(dot_root(g));
int margin, haveClustLabel = 0;
- if (g == agroot(g))
+ if (g == dot_root(g))
margin = CL_OFFSET;
else
margin = late_int (g, G_margin, CL_OFFSET, 0);
/* account for a possible cluster label in clusters */
/* room for root graph label is handled in dotneato_postprocess */
- if ((g != agroot(g)) && GD_label(g)) {
+ if ((g != dot_root(g)) && GD_label(g)) {
haveClustLabel = 1;
if (!GD_flip(agroot(g))) {
ht1 += GD_border(g)[BOTTOM_IX].y;
GD_ht2(g) = ht2;
/* update the global ranks */
- if (g != agroot(g)) {
+ if (g != dot_root(g)) {
rank[GD_minrank(g)].ht2 = MAX(rank[GD_minrank(g)].ht2, ht2);
rank[GD_maxrank(g)].ht1 = MAX(rank[GD_maxrank(g)].ht1, ht1);
}
node_t *v;
pointf LL, UR;
- if (g == agroot(g)) {
+ if (g == dot_root(g)) {
LL.x = (double)(INT_MAX);
UR.x = (double)(-INT_MAX);
for (r = GD_minrank(g); r <= GD_maxrank(g); r++) {
return lbound;
}
-static point place_leaf(node_t * leaf, point lbound, int order)
+static point place_leaf(graph_t* ing, node_t * leaf, point lbound, int order)
{
node_t *leader;
- graph_t *g = agraphof(leaf);
+ graph_t *g = dot_root(ing);
leader = UF_find(leaf);
if (leaf != leader)
for (e = agfstin(g, n); e; e = agnxtin(g, e)) {
edge_t *e1 = AGMKOUT(e);
if ((agtail(e1) != leader) && (UF_find(agtail(e1)) == leader)) {
- lbound = place_leaf(agtail(e1), lbound, j++);
+ lbound = place_leaf(g, agtail(e1), lbound, j++);
unmerge_oneway(e1);
elist_append(e1, ND_in(aghead(e1)));
}
j = ND_order(leader) + 1;
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
if ((aghead(e) != leader) && (UF_find(aghead(e)) == leader)) {
- lbound = place_leaf(aghead(e), lbound, j++);
+ lbound = place_leaf(g, aghead(e), lbound, j++);
unmerge_oneway(e);
elist_append(e, ND_out(agtail(e)));
}
if (GD_ln(g))
return;
- ln = virtual_node(agroot(g));
+ ln = virtual_node(dot_root(g));
ND_node_type(ln) = SLACKNODE;
- rn = virtual_node(agroot(g));
+ rn = virtual_node(dot_root(g));
ND_node_type(rn) = SLACKNODE;
- if (GD_label(g) && (g != agroot(g)) && !GD_flip(agroot(g))) {
+ if (GD_label(g) && (g != dot_root(g)) && !GD_flip(agroot(g))) {
int w = MAX(GD_border(g)[BOTTOM_IX].x, GD_border(g)[TOP_IX].x);
make_aux_edge(ln, rn, w, 0);
}