Esempio n. 1
0
/* isIn:
 * Return 1 if object objp is in subgraph gp.
 */
int isIn(Agraph_t * gp, Agobj_t * objp)
{
    if (!sameG(gp, objp, "isIn", 0))
	return 0;
    switch (AGTYPE(objp)) {
    case AGRAPH:
	return (agparent((Agraph_t *) objp) == gp);
    case AGNODE:
	return (agidnode(gp, AGID(objp), 0) != 0);
    default:
	return (agsubedge(gp, (Agedge_t *) objp, 0) != 0);
    }
}
Esempio n. 2
0
static void cc_dfs(Agraph_t* g, Agraph_t * comp, Agnode_t * n)
{
    Agedge_t *e;
    Agnode_t *other;

    CCMARK(n);
    agidnode(comp, AGID(n), 1);
    for (e = agfstedge(g, n); e; e = agnxtedge(g, e, n)) {
	if (agtail(e) == n)
	    other = aghead(e);
	else
	    other = agtail(e);
	if (!CCMARKED(other))
	    cc_dfs(g, comp, other);
    }
}
Esempio n. 3
0
/* compOf:
 * Return connected component of node.
 */
Agraph_t *compOf(Agraph_t * g, Agnode_t * n)
{
    Agraph_t *cg;
    Agnode_t *np;
    static int id;
    char name[64];

    if (!(n = agidnode(g, AGID(n), 0)))
	return 0;		/* n not in g */
    for (np = agfstnode(g); np; np = agnxtnode(g, np))
	CCUNMARK(np);

    sprintf(name, "_cc_%d", id++);
    cg = openSubg(g, name);
    cc_dfs(g, cg, n);

    return cg;
}