Agnode_t *other;
MARK(n) = 1;
+#ifndef WITH_CGRAPH
aginsert(out, n);
+#else /* WITH_CGRAPH */
+ agsubnode(out,n,1);
+#endif /* WITH_CGRAPH */
for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
- if ((other = e->tail) == n)
- other = e->head;
+ if ((other = agtail(e)) == n)
+ other = aghead(e);
if (!MARK(other))
dfs(g, other, out, marks);
}
/* Create component based on port nodes */
subg = 0;
if ((pp = PORTS(g))) {
- sprintf(name, "cc%s_%d", g->name, c_cnt++ + C_cnt);
+ sprintf(name, "cc%s_%d", agnameof(g), c_cnt++ + C_cnt);
+#ifndef WITH_CGRAPH
subg = agsubg(g, name);
+#else /* WITH_CGRAPH */
+ subg = agsubg(g, name,1);
+ agbindrec(subg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
GD_alg(subg) = (void *) NEW(gdata);
PORTS(subg) = pp;
NPORTS(subg) = NPORTS(g);
if (ND_pinned(n) != P_PIN)
continue;
if (!subg) {
- sprintf(name, "cc%s_%d", g->name, c_cnt++ + C_cnt);
+ sprintf(name, "cc%s_%d", agnameof(g), c_cnt++ + C_cnt);
+#ifndef WITH_CGRAPH
subg = agsubg(g, name);
+#else /* WITH_CGRAPH */
+ subg = agsubg(g, name,1);
+ agbindrec(subg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
GD_alg(subg) = (void *) NEW(gdata);
}
pinflag = 1;
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
if (MARK(n))
continue;
- sprintf(name, "cc%s+%d", g->name, c_cnt++ + C_cnt);
+ sprintf(name, "cc%s+%d", agnameof(g), c_cnt++ + C_cnt);
+#ifndef WITH_CGRAPH
subg = agsubg(g, name);
+#else /* WITH_CGRAPH */
+ subg = agsubg(g, name,1);
+ agbindrec(subg, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
GD_alg(subg) = (void *) NEW(gdata);
dfs(g, n, subg, marks);
nodeInduce(subg);
*pinned = pinflag;
/* freed in layout */
comps = cp = N_NEW(c_cnt + 1, graph_t *);
+#ifndef WITH_CGRAPH
mg = g->meta_node->graph;
for (me = agfstout(mg, g->meta_node); me; me = agnxtout(mg, me)) {
mn = me->head;
*cp++ = agusergraph(mn);
+#else /* WITH_CGRAPH */
+ for (me = agfstsubg(g); me; me = agnxtsubg(me)) {
+ *cp++ = me;
+#endif /* WITH_CGRAPH */
c_cnt--;
}
assert(c_cnt == 0);
char *p;
char c;
+#ifndef WITH_CGRAPH
possym = agfindattr(g->proto->n, "pos");
+#else /* WITH_CGRAPH */
+ possym = agattr(g,AGNODE, "pos",(char*)0);
+#endif /* WITH_CGRAPH */
if (!possym)
return;
+#ifndef WITH_CGRAPH
pinsym = agfindattr(g->proto->n, "pin");
+#else /* WITH_CGRAPH */
+ pinsym = agattr(g,AGNODE, "pin",(char*)0);
+#endif /* WITH_CGRAPH */
for (i = 0; (np = GD_neato_nlist(g)[i]); i++) {
+#ifndef WITH_CGRAPH
p = agxget(np, possym->index);
+#else /* WITH_CGRAPH */
+ p = agxget(np, possym);
+#endif /* WITH_CGRAPH */
if (p[0]) {
pvec = ND_pos(np);
c = '\0';
}
ND_pinned(np) = P_SET;
if ((c == '!')
+#ifndef WITH_CGRAPH
|| (pinsym && mapbool(agxget(np, pinsym->index))))
+#else /* WITH_CGRAPH */
+ || (pinsym && mapbool(agxget(np, pinsym))))
+#endif /* WITH_CGRAPH */
ND_pinned(np) = P_PIN;
} else
fprintf(stderr,
"Warning: node %s, position %s, expected two floats\n",
- np->name, p);
+ agnameof(np), p);
}
}
}
*/
static void init_edge(edge_t * e, attrsym_t * E_len)
{
+#ifdef WITH_CGRAPH
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
ED_factor(e) = late_double(e, E_weight, 1.0, 0.0);
ED_dist(e) = late_double(e, E_len, fdp_parms.K, 0.0);
ND_id(n) = i++;
}
+#ifndef WITH_CGRAPH
E_len = agfindattr(g->proto->e, "len");
+#else /* WITH_CGRAPH */
+ E_len = agattr(g,AGEDGE, "len",(char*)0);
+#endif /* WITH_CGRAPH */
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
init_edge(e, E_len);
static void cleanup_subgs(graph_t * g)
{
+#ifndef WITH_CGRAPH
graph_t *mg;
edge_t *me;
node_t *mn;
+#endif /* WITH_CGRAPH */
graph_t *subg;
+#ifndef WITH_CGRAPH
mg = g->meta_node->graph;
for (me = agfstout(mg, g->meta_node); me; me = agnxtout(mg, me)) {
mn = me->head;
subg = agusergraph(mn);
+#else /* WITH_CGRAPH */
+ for (subg = agfstsubg(g); subg; subg = agnxtsubg(subg)) {
+#endif /* WITH_CGRAPH */
free_label(GD_label(subg));
if (GD_alg(subg)) {
free(PORTS(subg));
cleanup_subgs(g);
free(GD_neato_nlist(g));
free(GD_alg(g));
+#ifndef WITH_CGRAPH
if (g != g->root) memset(&(g->u), 0, sizeof(Agraphinfo_t));
+#else /* WITH_CGRAPH */
+ if (g != agroot(g))
+ agclean(g,AGRAPH , "Agraphinfo_t");
+#endif /* WITH_CGRAPH */
}
void fdp_cleanup(graph_t * g)