extern Agedge_t *agnxtedge(Agraph_t * g, Agedge_t * e, Agnode_t * n);
/* generic */
-extern Agraph_t *agraphof(void *);
+extern Agraph_t *agraphof(void* obj);
+extern Agraph_t *agroot(void* obj);
extern char *agnameof(void *);
extern int agrelabel(void *obj, char *name); /* scary */
extern int agrelabel_node(Agnode_t * n, char *newname);
extern Agraph_t *agsubg(Agraph_t * g, char *name, int cflag); /* constructor */
extern Agraph_t *agidsubg(Agraph_t * g, unsigned long id, int cflag); /* constructor */
extern Agraph_t *agfstsubg(Agraph_t * g), *agnxtsubg(Agraph_t * subg);
-extern Agraph_t *agparent(Agraph_t * g), *agroot(Agraph_t * g);
+extern Agraph_t *agparent(Agraph_t * g);
/* set cardinality */
extern int agnnodes(Agraph_t * g), agnedges(Agraph_t * g);
fn(g, obj, cbstack->state);
}
+Agraph_t *agroot(void* obj)
+{
+ switch (AGTYPE(obj)) {
+ case AGINEDGE:
+ case AGOUTEDGE:
+ return ((Agedge_t *) obj)->node->root;
+ case AGNODE:
+ return ((Agnode_t *) obj)->root;
+ case AGRAPH:
+ return ((Agraph_t *) obj)->root;
+ default: /* actually can't occur if only 2 bit tags */
+ agerr(AGERR, "agroot of a bad object");
+ return NILgraph;
+ }
+}
+
Agraph_t *agraphof(void *obj)
{
switch (AGTYPE(obj)) {