static void set_data(Agobj_t * obj, Agrec_t * data, int mtflock) { Agedge_t *e; obj->data = data; obj->tag.mtflock = mtflock; if ((AGTYPE(obj) == AGINEDGE) || (AGTYPE(obj) == AGOUTEDGE)) { e = agopp((Agedge_t *) obj); AGDATA(e) = data; e->base.tag.mtflock = mtflock; } }
static v_data *makeGraph_old(topview * tv, int *nedges) { int i; int ne = tv->Edgecount; /* upper bound */ int nv = tv->Nodecount; v_data *graph = N_NEW(nv, v_data); int *edges = N_NEW(2 * ne + nv, int); /* reserve space for self loops */ float *ewgts = N_NEW(2 * ne + nv, float); Agnode_t *np; Agedge_t *ep; Agraph_t *g = NULL; int i_nedges; ne = 0; for (i = 0; i < nv; i++) { graph[i].edges = edges++; /* reserve space for the self loop */ graph[i].ewgts = ewgts++; #ifdef STYLES graph[i].styles = NULL; #endif i_nedges = 1; /* one for the self */ np = tv->Nodes[i].Node; if (!g) g = agraphof(np); for (ep = agfstedge(g, np); ep; ep = agnxtedge(g, ep, np)) { Agnode_t *vp; Agnode_t *tp = agtail(ep); Agnode_t *hp = aghead(ep); assert(hp != tp); /* FIX: handle multiedges */ vp = (tp == np ? hp : tp); ne++; i_nedges++; *edges++ = ((temp_node_record *) AGDATA(vp))->TVref; *ewgts++ = 1; } graph[i].nedges = i_nedges; graph[i].edges[0] = i; graph[i].ewgts[0] = 1 - i_nedges; } ne /= 2; /* each edge counted twice */ *nedges = ne; return graph; }
Agnodeinfo_t* ND_info(node_t * n) { return ((Agnodeinfo_t*)AGDATA(n));}
/* compute_bb: * Compute bounding box of g using nodes, splines, and clusters. * Assumes bb of clusters already computed. * store in GD_bb. */ void compute_bb(graph_t * g) { node_t *n; edge_t *e; boxf b, bb; boxf BF; pointf ptf, s2; int i, j; if ((agnnodes(g) == 0) && (GD_n_cluster(g) ==0)) { bb.LL = pointfof(0, 0); bb.UR = pointfof(0, 0); return; } bb.LL = pointfof(INT_MAX, INT_MAX); bb.UR = pointfof(-INT_MAX, -INT_MAX); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { ptf = coord(n); s2.x = ND_xsize(n) / 2.0; s2.y = ND_ysize(n) / 2.0; b.LL = sub_pointf(ptf, s2); b.UR = add_pointf(ptf, s2); EXPANDBB(bb,b); if (ND_xlabel(n) && ND_xlabel(n)->set) { bb = addLabelBB(bb, ND_xlabel(n), GD_flip(g)); } for (e = agfstout(g, n); e; e = agnxtout(g, e)) { if (ED_spl(e) == 0) continue; for (i = 0; i < ED_spl(e)->size; i++) { for (j = 0; j < (((Agedgeinfo_t*)AGDATA(e))->spl)->list[i].size; j++) { ptf = ED_spl(e)->list[i].list[j]; EXPANDBP(bb,ptf); } } if (ED_label(e) && ED_label(e)->set) { bb = addLabelBB(bb, ED_label(e), GD_flip(g)); } if (ED_head_label(e) && ED_head_label(e)->set) { bb = addLabelBB(bb, ED_head_label(e), GD_flip(g)); } if (ED_tail_label(e) && ED_tail_label(e)->set) { bb = addLabelBB(bb, ED_tail_label(e), GD_flip(g)); } if (ED_xlabel(e) && ED_xlabel(e)->set) { bb = addLabelBB(bb, ED_xlabel(e), GD_flip(g)); } } } for (i = 1; i <= GD_n_cluster(g); i++) { B2BF(GD_bb(GD_clust(g)[i]), BF); EXPANDBB(bb,BF); } if (GD_label(g) && GD_label(g)->set) { bb = addLabelBB(bb, GD_label(g), GD_flip(g)); } GD_bb(g) = bb; }
Agraphinfo_t* GD_info(graph_t * g) { return ((Agraphinfo_t*)AGDATA(g));}