From 360b943bc3fd0f1a9371a24e0aa7409393377607 Mon Sep 17 00:00:00 2001 From: north Date: Tue, 19 Jan 2010 02:22:54 +0000 Subject: [PATCH] Hook for recursion in aginit. --- lib/cgraph/cgraph.3 | 3 +++ lib/cgraph/main.c | 2 +- lib/cgraph/rec.c | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/cgraph/cgraph.3 b/lib/cgraph/cgraph.3 index 8a2c81754..b903735d2 100644 --- a/lib/cgraph/cgraph.3 +++ b/lib/cgraph/cgraph.3 @@ -324,6 +324,9 @@ Records are created and managed by Libcgraph. A programmer must explicitly attach them to the objects in a graph, either to individual objects one at a time via \fBagbindrec\fP, or to all the objects of the same class in a graph via \fBaginit\fP. +(Note that for graphs, aginit is applied recursively to the +graph and its subgraphs if rec_size is negative (of the +actual rec_size.)) The \fBname\fP argument a record distinguishes various types of records, and is programmer defined (Libcgraph reserves the prefix \fB_ag\fR). If size is 0, the call to \fBagbindrec\fP is simply a lookup. diff --git a/lib/cgraph/main.c b/lib/cgraph/main.c index e684f7c13..aa979b6e5 100644 --- a/lib/cgraph/main.c +++ b/lib/cgraph/main.c @@ -15,7 +15,7 @@ **********************************************************/ #include -#include +#include static void prstats(Agraph_t * g, int verbose); static void do_it(Agraph_t * g, int dostat); diff --git a/lib/cgraph/rec.c b/lib/cgraph/rec.c index ebbe4bcd5..00bf46a46 100644 --- a/lib/cgraph/rec.c +++ b/lib/cgraph/rec.c @@ -202,10 +202,17 @@ void aginit(Agraph_t * g, int kind, char *rec_name, int rec_size, int mtf) { Agnode_t *n; Agedge_t *e; + Agraph_t *s; + int rec; switch (kind) { case AGRAPH: + rec = (rec_size < 0); + if (rec) rec_size = -rec_size; agbindrec(g, rec_name, rec_size, mtf); + if (rec) + for (s = agfstsubg(g); s; s = agnxtsubg(s)) + aginit(s,kind,rec_name,rec_size,mtf); break; case AGNODE: case AGOUTEDGE: -- 2.40.0