/* cloneSubg: * Clone subgraph sg in tgt. */ static Agraph_t *cloneSubg(Agraph_t * tgt, Agraph_t * g, Dt_t* emap) { Agraph_t *ng; Agraph_t *sg; Agnode_t *t; Agnode_t *newt; Agedge_t *e; Agedge_t *newe; char* name; ng = (Agraph_t *) (copy(tgt, OBJ(g))); if (!ng) return 0; for (t = agfstnode(g); t; t = agnxtnode(g, t)) { newt = agnode(tgt, agnameof(t), 0); if (!newt) { exerror("node %s not found in cloned graph %s", agnameof(t), agnameof(tgt)); return 0; } else agsubnode(ng, newt, 1); } for (t = agfstnode(g); t; t = agnxtnode(g, t)) { for (e = agfstout(g, t); e; e = agnxtout(g, e)) { newe = mapEdge (emap, e); if (!newe) { name = agnameof(AGMKOUT(e)); if (name) exerror("edge (%s,%s)[%s] not found in cloned graph %s", agnameof(agtail(e)), agnameof(aghead(e)), name, agnameof(tgt)); else exerror("edge (%s,%s) not found in cloned graph %s", agnameof(agtail(e)), agnameof(aghead(e)), agnameof(tgt)); return 0; } else agsubedge(ng, newe, 1); } } for (sg = agfstsubg(g); sg; sg = agnxtsubg(sg)) { if (!cloneSubg(ng, sg, emap)) { exerror("error cloning subgraph %s from graph %s", agnameof(sg), agnameof(g)); return 0; } } return ng; }
static void nodeInduce(Agraph_t * g) { Agnode_t *n, *rootn; Agedge_t *e; for (n = agfstnode(g); n; n = agnxtnode(n)) { rootn = agsubnode(agroot(g), n, FALSE); for (e = agfstout(rootn); e; e = agnxtout(e)) { if (agsubnode(g, aghead(e), FALSE)) agsubedge(g, e, TRUE); else { if (getscc(aghead(e)) && getscc(agtail(e))) agedge(getrep(getscc(agtail(e))), getrep(getscc(aghead(e))), NIL(char *), TRUE); } } } }
/* nodeInduce: * Add all edges in root graph connecting two nodes in * selected to selected. */ void nodeInduce(Agraph_t * selected) { Agnode_t *n; Agedge_t *e; Agraph_t *base; if (!selected) return; base = agroot(selected); if (base == selected) return; for (n = agfstnode(selected); n; n = agnxtnode(selected, n)) { for (e = agfstout(base, n); e; e = agnxtout(base, e)) { if (agsubnode(selected, aghead(e), FALSE)) agsubedge(selected, e, TRUE); } } }
/* cloneSubg: * Clone subgraph sg in tgt. */ static Agraph_t *cloneSubg(Agraph_t * tgt, Agraph_t * g) { Agraph_t *ng; Agraph_t *sg; Agnode_t *t; Agnode_t *newt; Agnode_t *newh; Agedge_t *e; Agedge_t *newe; ng = (Agraph_t *) (copy(tgt, OBJ(g))); if (!ng) return 0; for (t = agfstnode(g); t; t = agnxtnode(t)) { newt = agnode(tgt, agnameof(t), 0); if (!newt) error(ERROR_PANIC, "node %s not found in cloned graph %s", agnameof(t), agnameof(tgt)); agsubnode(ng, newt, 1); } for (t = agfstnode(g); t; t = agnxtnode(t)) { newt = agnode(tgt, agnameof(t), 0); for (e = agfstout(t); e; e = agnxtout(e)) { newh = agnode(tgt, agnameof(aghead(e)), 0); newe = agedge(newt, newh, agnameof(e), 0); if (!newe) error(ERROR_PANIC, "edge (%s,%s)[%s] not found in cloned graph %s", agnameof(agtail(e)), agnameof(aghead(e)), agnameof(e), agnameof(tgt)); agsubedge(ng, newe, 1); } } for (sg = agfstsubg(g); sg; sg = agnxtsubg(sg)) { if (!cloneSubg(ng, sg)) { error(ERROR_FATAL, "error cloning subgraph %s from graph %s", agnameof(sg), agnameof(g)); } } return ng; }
static void nodeInduce(Agraph_t * g, Agraph_t* map) { Agnode_t *n; Agedge_t *e; Agraph_t* rootg = agroot (g); for (n = agfstnode(g); n; n = agnxtnode(g, n)) { for (e = agfstout(rootg, n); e; e = agnxtout(rootg, e)) { if (agsubnode(g, aghead(e), FALSE)) agsubedge(g, e, TRUE); else { Agraph_t* tscc = getscc(agtail(e)); Agraph_t* hscc = getscc(aghead(e)); if (tscc && hscc) agedge(map, getrep(tscc), getrep(hscc), NIL(char *), TRUE); } } } }
static Agobj_t *subedge_search(Agraph_t * sub, Agobj_t * e) { if (agraphof(e) == sub) return e; return (Agobj_t *) agsubedge(sub, (Agedge_t *) e, FALSE); }
/* addEdge: * Insert edge e into subgraph g. * Return image of e */ Agedge_t *addEdge(Agraph_t * gp, Agedge_t * ep, int doAdd) { if (!sameG(gp, ep, "addEdge", 0)) return 0; return agsubedge(gp, ep, doAdd); }
/* addEdge: * Insert edge e into subgraph g. * Return image of e */ Agedge_t *addEdge(Agraph_t * gp, Agedge_t * ep) { if (!sameG(gp, ep, "addEdge", 0)) return 0; return agsubedge(gp, ep, 1); }