static int id = 0;
sprintf(gname, "_clone_%d", id++);
+#ifndef WITH_CGRAPH
clone = agsubg(ing, gname);
+#else /* WITH_CGRAPH */
+ clone = agsubg(ing, gname,1);
+ agbindrec(clone, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
sprintf(gname, "_clone_%d", id++);
+#ifndef WITH_CGRAPH
xclone = agopen(gname, ing->kind);
-
for (n = agfstnode(ing); n; n = agnxtnode(ing, n)) {
aginsert(clone, n);
- xn = agnode(xclone, n->name);
+ xn = agnode(xclone, agnameof(n));
+#else /* WITH_CGRAPH */
+ xclone = agopen(gname, ing->desc,NIL(Agdisc_t *));
+ for (n = agfstnode(ing); n; n = agnxtnode(ing, n)) {
+ agsubnode(clone,n,1);
+ xn = agnode(xclone, agnameof(n),1);
+ agbindrec(xn, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
CLONE(n) = xn;
}
for (n = agfstnode(ing); n; n = agnxtnode(ing, n)) {
xn = CLONE(n);
+#ifndef WITH_CGRAPH
for (e = agfstout(ing, n); e; e = agnxtout(ing, e)) {
aginsert(clone, e);
xh = CLONE(e->head);
xe = agedge(xclone, xn, xh);
+#else /* WITH_CGRAPH */
+ for (e = agfstout(ing, n); e; e = agnxtout(ing, e)) {
+ agsubedge(clone,e,1);
+ xh = CLONE(aghead(e));
+ xe = agedge(xclone, xn, xh,(char*)0,1);
+ agbindrec(xe, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
ORIGE(xe) = e;
DEGREE(xn) += 1;
DEGREE(xh) += 1;
for (n = agfstnode(root); n; n = agnxtnode(root, n)) {
Agnode_t *t = agnode(clone, n);
for (e = agfstout(root, n); e; e = agnxtout(root, e)) {
- Agnode_t *h = agnode(clone, e->head->name);
+ Agnode_t *h = agnode(clone, agnameof(aghead(e)));
agedge(clone, t, h);
}
}
neighbors_without = N_GNEW(node_degree, Agnode_t *);
for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
- n1 = e->head;
+ n1 = aghead(e);
if (n1 == n)
- n1 = e->tail;
+ n1 = agtail(e);
has_pair_edge = 0;
for (ep = agfstedge(g, n); ep; ep = agnxtedge(g, ep, n)) {
if (ep == e)
continue;
- n2 = ep->head;
+ n2 = aghead(ep);
if (n2 == n)
- n2 = ep->tail;
+ n2 = agtail(ep);
+#ifndef WITH_CGRAPH
ex = agfindedge(g, n1, n2);
+#else /* WITH_CGRAPH */
+ ex = agedge(g, n1, n2,(char*)0,0);
+#endif /* WITH_CGRAPH */
if (ex) {
has_pair_edge = 1;
if (n1 < n2) { /* count edge only once */
break;
tp = neighbors_without[mark];
hp = neighbors_without[mark + 1];
+#ifndef WITH_CGRAPH
agedge(g, tp, hp);
+#else /* WITH_CGRAPH */
+ agbindrec(agedge(g, tp, hp,(char*)0,1), "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+
+#endif /* WITH_CGRAPH */
DEGREE(tp)++;
DEGREE(hp)++;
diff--;
while (diff > 0) {
tp = neighbors_without[0];
hp = neighbors_without[mark];
+#ifndef WITH_CGRAPH
agedge(g, tp, hp);
+#else /* WITH_CGRAPH */
+
+ agbindrec(agedge(g, tp, hp,(char*)0,1), "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+
+#endif /* WITH_CGRAPH */
DEGREE(tp)++;
DEGREE(hp)++;
mark++;
tp = neighbors_with[0];
for (mark = 0; mark < no_pair_count; mark++) {
hp = neighbors_without[mark];
+#ifndef WITH_CGRAPH
agedge(g, tp, hp);
+#else /* WITH_CGRAPH */
+ agbindrec(agedge(g, tp, hp,(char*)0,1), "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+
+#endif /* WITH_CGRAPH */
DEGREE(tp)++;
DEGREE(hp)++;
}
/* Remove all adjacent nodes since they have to be reinserted */
for (e = agfstedge(g, currnode); e; e = agnxtedge(g, e, currnode)) {
- adjNode = e->head;
+ adjNode = aghead(e);
if (currnode == adjNode)
- adjNode = e->tail;
+ adjNode = agtail(e);
removeDeglist(dl, adjNode);
}
find_pair_edges(g, currnode, outg);
for (e = agfstedge(g, currnode); e; e = agnxtedge(g, e, currnode)) {
- adjNode = e->head;
+ adjNode = aghead(e);
if (currnode == adjNode)
- adjNode = e->tail;
+ adjNode = agtail(e);
DEGREE(adjNode)--;
insertDeglist(dl, adjNode);
SET_VISITED(n);
for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
- neighbor = e->head;
+ neighbor = aghead(e);
if (neighbor == n)
- neighbor = e->tail;
+ neighbor = agtail(e);
if (!VISITED(neighbor)) {
/* add the edge to the dfs tree */
+#ifndef WITH_CGRAPH
aginsert(tree, e);
+#else /* WITH_CGRAPH */
+ agsubedge(tree,e,1);
+#endif /* WITH_CGRAPH */
TPARENT(neighbor) = n;
dfs(g, neighbor, tree);
}
static int id = 0;
sprintf(gname, "_span_%d", id++);
+#ifndef WITH_CGRAPH
tree = agsubg(g, gname);
+#else /* WITH_CGRAPH */
+ tree = agsubg(g, gname,1);
+ agbindrec(tree, "Agraphinfo_t", sizeof(Agraphinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
+
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
+#ifndef WITH_CGRAPH
aginsert(tree, n);
+#else /* WITH_CGRAPH */
+ agsubnode(tree,n,1);
+#endif /* WITH_CGRAPH */
DISTONE(n) = 0;
DISTTWO(n) = 0;
UNSET_VISITED(n);
for (n = agfstnode(subg); n; n = agnxtnode(subg, n)) {
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
- if (BLOCK(e->head) == sn)
+ if (BLOCK(aghead(e)) == sn)
+#ifndef WITH_CGRAPH
aginsert(subg, e);
+#else /* WITH_CGRAPH */
+ agsubedge(subg,e,1);
+#endif /* WITH_CGRAPH */
}
}
}
(edgelistitem *) dtnext(openEdgeList, eitem)) {
ep = eitem->edge;
if (EDGEORDER(ep) > EDGEORDER(e)) {
- if ((ep->head != n) && (ep->tail != n))
+ if ((aghead(ep) != n) && (agtail(ep) != n))
crossings++;
}
}
/* move curnode next to its neighbors */
for (e = agfstedge(subg, curnode); e;
e = agnxtedge(subg, e, curnode)) {
- neighbor = e->tail;
+ neighbor = agtail(e);
if (neighbor == curnode)
- neighbor = e->head;
+ neighbor = aghead(e);
for (j = 0; j < 2; j++) {
listCopy = cloneNodelist(list);
nodelistitem_t *one, *two;
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
- appendNodelist(neighbors, NULL, e->head);
- SET_NEIGHBOR(e->head);
+ appendNodelist(neighbors, NULL, aghead(e));
+ SET_NEIGHBOR(aghead(e));
}
for (e = agfstin(g, n); e; e = agnxtin(g, e)) {
- appendNodelist(neighbors, NULL, e->tail);
- SET_NEIGHBOR(e->tail);
+ appendNodelist(neighbors, NULL, agtail(e));
+ SET_NEIGHBOR(agtail(e));
}
/* Look for 2 neighbors consecutive on list */
static void addNode(block_t * bp, Agnode_t * n)
{
+#ifndef WITH_CGRAPH
aginsert(bp->sub_graph, n);
+#else /* WITH_CGRAPH */
+ agsubnode(bp->sub_graph, n,1);
+#endif /* WITH_CGRAPH */
SET_BCDONE(n);
BLOCK(n) = bp;
}
Agraph_t *subg;
sprintf(name, "_block_%d", state->blockCount++);
+#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 */
return subg;
}
stackPush(state->bcstack, n);
for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
- Agnode_t *neighbor = e->head;
+ Agnode_t *neighbor = aghead(e);
if (neighbor == n)
- neighbor = e->tail;
+ neighbor = agtail(e);
if (neighbor == PARENT(n))
continue;
/* check to see if there is a node which is set to be the root
*/
if (state->rootname) {
+#ifndef WITH_CGRAPH
root = agfindnode(g, state->rootname);
+#else /* WITH_CGRAPH */
+ root = agnode(g, state->rootname,0);
+#endif /* WITH_CGRAPH */
}
if (!root && state->N_root) {
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
Agraph_t *subg = bp->sub_graph;
child = n = agfstnode(subg);
+
min = VAL(n);
parent = PARENT(n);
for (n = agnxtnode(subg, n); n; n = agnxtnode(subg, n)) {
static void circular_init_edge(edge_t * e)
{
+#ifdef WITH_CGRAPH
+ agbindrec(e, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
common_init_edge(e);
ED_factor(e) = late_double(e, E_weight, 1.0, 0.0);
GD_neato_nlist(g) = N_NEW(agnnodes(g) + 1, node_t *);
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
+ neato_init_node(n);
ND_alg(n) = alg + i;
GD_neato_nlist(g)[i++] = n;
- neato_init_node(n);
}
for (n = agfstnode(g); n; n = agnxtnode(g, n)) {
for (e = agfstout(g, n); e; e = agnxtout(g, e)) {
static node_t *makeDerivedNode(graph_t * dg, char *name, int isNode,
void *orig)
{
+#ifndef WITH_CGRAPH
node_t *n = agnode(dg, name);
+#else /* WITH_CGRAPH */
+ node_t *n = agnode(dg, name,1);
+ agbindrec(n, "Agnodeinfo_t", sizeof(Agnodeinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
ND_alg(n) = (void *) NEW(cdata);
if (isNode) {
ND_pos(n) = N_NEW(Ndim, double);
Agedge_t *me;
#endif
+#ifndef WITH_CGRAPH
dg = agopen("derived", AGFLAG_STRICT);
+#else /* WITH_CGRAPH */
+ dg = agopen("derived", Agstrictundirected,NIL(Agdisc_t *));
+#endif /* WITH_CGRAPH */
GD_alg(g) = dg; /* store derived graph for closing later */
#ifdef USER_BLOCKS
sg = g->meta_node->graph;
for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
if (DNODE(v))
continue;
- n = makeDerivedNode(dg, v->name, 1, v);
+ n = makeDerivedNode(dg, agnameof(v), 1, v);
DNODE(v) = n;
}
for (v = agfstnode(g); v; v = agnxtnode(g, v)) {
for (e = agfstout(g, v); e; e = agnxtout(g, e)) {
- dt = DNODE(e->tail);
- dh = DNODE(e->head);
- if (dt != dh)
+ dt = DNODE(agtail(e));
+ dh = DNODE(aghead(e));
+ if (dt != dh) {
+#ifndef WITH_CGRAPH
agedge(dg, dt, dh);
+#else /* WITH_CGRAPH */
+ agbindrec(agedge(dg, dt, dh,(char*)0,1), "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+#endif /* WITH_CGRAPH */
+ }
}
}
for (n = agfstnode(sg); n; n = agnxtnode(sg, n)) {
p = ORIGN(n);
for (e = agfstout(g, p); e; e = agnxtout(g, e)) {
- /* n = DNODE(e->tail); by construction since e->tail == p */
- dh = DNODE(e->head);
+ /* n = DNODE(agtail(e)); by construction since agtail(e) == p */
+ dh = DNODE(aghead(e));
if (n != dh) {
+#ifndef WITH_CGRAPH
ep = agedge(dg, n, dh);
aginsert(sg, ep);
+#else /* WITH_CGRAPH */
+ ep = agedge(dg, n, dh,(char*)0,1);
+ agbindrec(ep, "Agedgeinfo_t", sizeof(Agedgeinfo_t), TRUE); //node custom data
+ agsubedge(sg,ep,1);
+#endif /* WITH_CGRAPH */
}
}
}
gv_cleanup_node(n);
}
free(GD_neato_nlist(g));
- if (g != g->root) memset(&(g->u), 0, sizeof(Agraphinfo_t));
+ if (g != agroot(g))
+#ifndef WITH_CGRAPH
+ memset(&(g->u), 0, sizeof(Agraphinfo_t));
+#else /* WITH_CGRAPH */
+ agclean (g,AGRAPH,"Agraphinfo_t");
+#endif /* WITH_CGRAPH */
}