From: Emden Gansner Date: Tue, 25 Oct 2011 16:31:43 +0000 (-0400) Subject: Make sure new rank function works with cgraph; X-Git-Tag: LAST_LIBGRAPH~32^2~617^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4242aba789abaeaac575c7fc868423c37f0c3ab5;p=graphviz Make sure new rank function works with cgraph; clean up allocated node edge lists in level graph --- diff --git a/lib/dotgen/rank.c b/lib/dotgen/rank.c index bccb611d9..2fa21e41f 100644 --- a/lib/dotgen/rank.c +++ b/lib/dotgen/rank.c @@ -29,9 +29,8 @@ #include "dot.h" static void dot1_rank(graph_t * g, aspect_t* asp); -#ifdef WITH_CGRAPH +#ifdef WITH_NEW_RANK static void dot2_rank(graph_t * g, aspect_t* asp); -static void node_induce(graph_t * par, graph_t * g); #endif static void @@ -1216,6 +1215,32 @@ static void add_fast_edges (graph_t * g) } } +#ifdef WITH_CGRAPH +static void my_init_graph(Agraph_t *g, Agobj_t *graph, void *arg) +{ int *sz = arg; agbindrec(graph,"level graph rec",sz[0],TRUE); } +static void my_init_node(Agraph_t *g, Agobj_t *node, void *arg) +{ int *sz = arg; agbindrec(node,"level node rec",sz[1],TRUE); } +static void my_init_edge(Agraph_t *g, Agobj_t *edge, void *arg) +{ int *sz = arg; agbindrec(edge,"level edge rec",sz[2],TRUE); } +static Agcbdisc_t mydisc = { {my_init_graph,0,0}, {my_init_node,0,0}, {my_init_edge,0,0} }; + +int infosizes[] = { + sizeof(Agraphinfo_t), + sizeof(Agnodeinfo_t), + sizeof(Agedgeinfo_t) +}; +#endif + +static void +cleanLevelGraph (graph_t * g) +{ + node_t* n; + for (n = agfstnode(g); n; n = agnxtnode(g, n)) { + free_list (ND_out(n)); + free_list (ND_in(n)); + } +} + void dot2_rank(graph_t * g, aspect_t* asp) { int ssize; @@ -1224,7 +1249,12 @@ void dot2_rank(graph_t * g, aspect_t* asp) #ifdef ALLOW_LEVELS attrsym_t* N_level; #endif + Last_node = NULL; graph_t *Xg = agopen("level assignment constraints", Agstrictdirected, 0); +#ifdef WITH_CGRAPH + agbindrec(Xg,"level graph rec",sizeof(Agraphinfo_t),TRUE); + agpushdisc(Xg,&mydisc,infosizes); +#endif edgelabel_ranks(g); @@ -1256,6 +1286,7 @@ void dot2_rank(graph_t * g, aspect_t* asp) #ifdef DEBUG fprintf (stderr, "Xg %d nodes %d edges\n", agnnodes(Xg), agnedges(Xg)); #endif + cleanLevelGraph (Xg); agclose(Xg); }