static int rank_set_class(graph_t * g) { static char *name[] = { "same", "min", "source", "max", "sink", NULL }; static int class[] = { SAMERANK, MINRANK, SOURCERANK, MAXRANK, SINKRANK, 0 }; int val; if (is_cluster(g)) return CLUSTER; val = maptoken(agget(g, "rank"), name, class); GD_set_type(g) = val; return val; } static int make_new_cluster(graph_t * g, graph_t * subg) { int cno; cno = ++(GD_n_cluster(g)); GD_clust(g) = ZALLOC(cno + 1, GD_clust(g), graph_t *, GD_n_cluster(g)); GD_clust(g)[cno] = subg; do_graph_label(subg); return cno; }
static void find_clusters(graph_t * g) { graph_t *subg; for (subg = agfstsubg(dot_root(g)); subg; subg = agnxtsubg(subg)) { if (GD_set_type(subg) == CLUSTER) collapse_cluster(g, subg); } }
int rank_set_class(graph_t* g) { static char *name[] = {"same","min","source","max","sink",NULL}; static int class[] = {SAMERANK,MINRANK,SOURCERANK,MAXRANK,SINKRANK,0}; int val; if (is_cluster(g)) return CLUSTER; val = maptoken(agget(g,"rank"),name,class); GD_set_type(g) = val; return val; } /* Execute union commands for "same rank" subgraphs and clusters. */ void collapse_sets(graph_t* g) { int c; graph_t *mg,*subg; node_t *mn,*n; edge_t *me; mg = g->meta_node->graph; for (me = agfstout(mg,g->meta_node); me; me = agnxtout(mg,me)) { mn = me->head; subg = agusergraph(mn); c = rank_set_class(subg); if (c) { if ((c == CLUSTER) && CL_type == LOCAL) collapse_cluster(g,subg); else collapse_rankset(g,subg,c); } /* mark nodes with ordered edges so their leaves are not collapsed */ if (agget(subg,"ordering")) for (n = agfstnode(subg); n; n = agnxtnode(subg,n)) ND_order(n) = 1; } }
/* Execute union commands for "same rank" subgraphs and clusters. */ static void collapse_sets(graph_t *rg, graph_t *g) { int c; graph_t *subg; #ifdef OBSOLETE node_t *n; #endif #ifndef WITH_CGRAPH graph_t *mg; node_t *mn; edge_t *me; mg = g->meta_node->graph; for (me = agfstout(mg, g->meta_node); me; me = agnxtout(mg, me)) { mn = aghead(me); subg = agusergraph(mn); #else /* WITH_CGRAPH */ for (subg = agfstsubg(g); subg; subg = agnxtsubg(subg)) { #endif /* WITH_CGRAPH */ c = rank_set_class(subg); if (c) { if ((c == CLUSTER) && CL_type == LOCAL) collapse_cluster(rg, subg); else collapse_rankset(rg, subg, c); } else collapse_sets(rg, subg); #ifdef OBSOLETE Collapsing leaves is currently obsolete /* mark nodes with ordered edges so their leaves are not collapsed */ if (agget(subg, "ordering")) for (n = agfstnode(subg); n; n = agnxtnode(subg, n)) ND_order(n) = 1; #endif } } static void find_clusters(graph_t * g) { graph_t *subg; #ifndef WITH_CGRAPH graph_t *mg; node_t *mn; edge_t *me; 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(agroot(g)); subg; subg = agnxtsubg(subg)) { #endif /* WITH_CGRAPH */ if (GD_set_type(subg) == CLUSTER) collapse_cluster(g, subg); } } static void set_minmax(graph_t * g) { int c; GD_minrank(g) += ND_rank(GD_leader(g)); GD_maxrank(g) += ND_rank(GD_leader(g)); for (c = 1; c <= GD_n_cluster(g); c++) set_minmax(GD_clust(g)[c]); }