From: north Date: Wed, 14 Nov 2007 21:00:49 +0000 (+0000) Subject: clean up fastgraphs X-Git-Tag: LAST_LIBGRAPH~32^2~5028 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5a1e7798bb051a749c059e076708ae814412ca8;p=graphviz clean up fastgraphs --- diff --git a/lib/cgraph/cgraph.h b/lib/cgraph/cgraph.h index 20cea5e79..c430b642b 100644 --- a/lib/cgraph/cgraph.h +++ b/lib/cgraph/cgraph.h @@ -402,6 +402,34 @@ extern int agerrors(void); extern Agdesc_t Agdirected, Agstrictdirected, Agundirected, Agstrictundirected; +/* fast graphs */ +void agflatten(Agraph_t * g, int flag); +typedef Agsubnode_t Agnoderef_t; +typedef Dtlink_t Agedgeref_t; + +#define AGHEADPOINTER(g) ((Agnoderef_t*)(g->n_seq->data->hh._head)) +#define AGRIGHTPOINTER(rep) ((Agnoderef_t*)((rep)->seq_link.right?((void*)((rep)->seq_link.right) - offsetof(Agsubnode_t,seq_link)):0)) +#define AGLEFTPOINTER(rep) ((Agnoderef_t*)((rep)->seq_link.hl._left?((void*)((rep)->seq_link.hl._left) - offsetof(Agsubnode_t,seq_link)):0)) + +#define FIRSTNREF(g) (agflatten(g,1), AGHEADPOINTER(g)) + +#define NEXTNREF(g,rep) (AGRIGHTPOINTER(rep) == AGHEADPOINTER(g)?0:AGRIGHTPOINTER(rep)) + +#define PREVNREF(g,rep) (((rep)==AGHEADPOINTER(g))?0:(AGLEFTPOINTER(rep))) + +#define LASTNREF(g) (agflatten(g,1), AGHEADPOINTER(g)?AGLEFTPOINTER(AGHEADPOINTER(g)):0) +#define NODEOF(rep) ((rep)->node) + +#define FIRSTOUTREF(g,sn) (agflatten(g,1), (sn)->out_seq) +#define LASTOUTREF(g,sn) (agflatten(g,1), (Agedgeref_t*)dtlast(sn->out_seq)) +#define FIRSTINREF(g,sn) (agflatten(g,1), (sn)->in_seq) +#define NEXTEREF(g,rep) ((rep)->right) +#define PREVEREF(g,rep) ((rep)->hl._left) +/* this is expedient but a bit slimey because it "knows" that dict entries of both nodes +and edges are embedded in main graph objects but allocated separately in subgraphs */ +#define AGSNMAIN(sn) ((sn)==(&((sn)->node->mainsub))) +#define EDGEOF(sn,rep) (AGSNMAIN(sn)?((Agedge_t*)((unsigned char*)(rep) - offsetof(Agedge_t,seq_link))) : ((Dthold_t*)(rep))->obj) + #undef extern #if _PACKAGE_ast _END_EXTERNS_