annotate toolboxes/graph_visualisation/include/graphviz/cgraph.h @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 /* $Id: cgraph.h,v 1.16 2009/07/10 21:10:32 erg Exp $ $Revision: 1.16 $ */
Daniel@0 2 /* vim:set shiftwidth=4 ts=8: */
Daniel@0 3
Daniel@0 4 /**********************************************************
Daniel@0 5 * This software is part of the graphviz package *
Daniel@0 6 * http://www.graphviz.org/ *
Daniel@0 7 * *
Daniel@0 8 * Copyright (c) 1994-2004 AT&T Corp. *
Daniel@0 9 * and is licensed under the *
Daniel@0 10 * Common Public License, Version 1.0 *
Daniel@0 11 * by AT&T Corp. *
Daniel@0 12 * *
Daniel@0 13 * Information and Software Systems Research *
Daniel@0 14 * AT&T Research, Florham Park NJ *
Daniel@0 15 **********************************************************/
Daniel@0 16
Daniel@0 17 #ifndef ATT_GRAPH_H
Daniel@0 18 #define ATT_GRAPH_H
Daniel@0 19
Daniel@0 20 #include "cdt.h"
Daniel@0 21
Daniel@0 22 #ifdef __cplusplus
Daniel@0 23 extern "C" {
Daniel@0 24 #endif
Daniel@0 25
Daniel@0 26 #ifndef FALSE
Daniel@0 27 #define FALSE (0)
Daniel@0 28 #endif
Daniel@0 29 #ifndef TRUE
Daniel@0 30 #define TRUE (!FALSE)
Daniel@0 31 #endif
Daniel@0 32 #ifndef NOT
Daniel@0 33 #define NOT(x) (!(x))
Daniel@0 34 #endif
Daniel@0 35 #ifndef NIL
Daniel@0 36 #define NIL(type) ((type)0)
Daniel@0 37 #endif
Daniel@0 38 #define NILgraph NIL(Agraph_t*)
Daniel@0 39 #define NILnode NIL(Agnode_t*)
Daniel@0 40 #define NILedge NIL(Agedge_t*)
Daniel@0 41 #define NILsym NIL(Agsym_t*)
Daniel@0 42
Daniel@0 43 /* forward struct type declarations */
Daniel@0 44 typedef struct Agtag_s Agtag_t;
Daniel@0 45 typedef struct Agobj_s Agobj_t; /* generic object header */
Daniel@0 46 typedef struct Agraph_s Agraph_t; /* graph, subgraph (or hyperedge) */
Daniel@0 47 typedef struct Agnode_s Agnode_t; /* node (atom) */
Daniel@0 48 typedef struct Agedge_s Agedge_t; /* node pair */
Daniel@0 49 typedef struct Agdesc_s Agdesc_t; /* graph descriptor */
Daniel@0 50 typedef struct Agmemdisc_s Agmemdisc_t; /* memory allocator */
Daniel@0 51 typedef struct Agiddisc_s Agiddisc_t; /* object ID allocator */
Daniel@0 52 typedef struct Agiodisc_s Agiodisc_t; /* IO services */
Daniel@0 53 typedef struct Agdisc_s Agdisc_t; /* union of client discipline methods */
Daniel@0 54 typedef struct Agdstate_s Agdstate_t; /* client state (closures) */
Daniel@0 55 typedef struct Agsym_s Agsym_t; /* string attribute descriptors */
Daniel@0 56 typedef struct Agattr_s Agattr_t; /* string attribute container */
Daniel@0 57 typedef struct Agcbdisc_s Agcbdisc_t; /* client event callbacks */
Daniel@0 58 typedef struct Agcbstack_s Agcbstack_t; /* enclosing state for cbdisc */
Daniel@0 59 typedef struct Agclos_s Agclos_t; /* common fields for graph/subgs */
Daniel@0 60 typedef struct Agrec_s Agrec_t; /* generic runtime record */
Daniel@0 61 typedef struct Agdatadict_s Agdatadict_t; /* set of dictionaries per graph */
Daniel@0 62 typedef struct Agedgepair_s Agedgepair_t; /* the edge object */
Daniel@0 63 typedef struct Agsubnode_s Agsubnode_t;
Daniel@0 64
Daniel@0 65 /* Header of a user record. These records are attached by client programs
Daniel@0 66 dynamically at runtime. A unique string ID must be given to each record
Daniel@0 67 attached to the same object. Cgraph has functions to create, search for,
Daniel@0 68 and delete these records. The records are maintained in a circular list,
Daniel@0 69 with obj->data pointing somewhere in the list. The search function has
Daniel@0 70 an option to lock this pointer on a given record. The application must
Daniel@0 71 be written so only one such lock is outstanding at a time. */
Daniel@0 72
Daniel@0 73 struct Agrec_s {
Daniel@0 74 char *name;
Daniel@0 75 Agrec_t *next;
Daniel@0 76 /* following this would be any programmer-defined data */
Daniel@0 77 };
Daniel@0 78
Daniel@0 79 /* Object tag for graphs, nodes, and edges. While there may be several structs
Daniel@0 80 for a given node or edges, there is only one unique ID (per main graph). */
Daniel@0 81 struct Agtag_s {
Daniel@0 82 unsigned objtype:2; /* see literal tags below */
Daniel@0 83 unsigned mtflock:1; /* move-to-front lock, see above */
Daniel@0 84 unsigned attrwf:1; /* attrs written (parity, write.c) */
Daniel@0 85 unsigned seq:(sizeof(unsigned) * 8 - 4); /* sequence no. */
Daniel@0 86 unsigned long id; /* client ID */
Daniel@0 87 };
Daniel@0 88
Daniel@0 89 /* object tags */
Daniel@0 90 #define AGRAPH 0 /* can't exceed 2 bits. see Agtag_t. */
Daniel@0 91 #define AGNODE 1
Daniel@0 92 #define AGOUTEDGE 2
Daniel@0 93 #define AGINEDGE 3 /* (1 << 1) indicates an edge tag. */
Daniel@0 94 #define AGEDGE AGOUTEDGE /* synonym in object kind args */
Daniel@0 95
Daniel@0 96 /* a generic graph/node/edge header */
Daniel@0 97 struct Agobj_s {
Daniel@0 98 Agtag_t tag;
Daniel@0 99 Agrec_t *data;
Daniel@0 100 };
Daniel@0 101
Daniel@0 102 #define AGTAG(obj) (((Agobj_t*)(obj))->tag)
Daniel@0 103 #define AGTYPE(obj) (AGTAG(obj).objtype)
Daniel@0 104 #define AGID(obj) (AGTAG(obj).id)
Daniel@0 105 #define AGSEQ(obj) (AGTAG(obj).seq)
Daniel@0 106 #define AGATTRWF(obj) (AGTAG(obj).attrwf)
Daniel@0 107 #define AGDATA(obj) (((Agobj_t*)(obj))->data)
Daniel@0 108
Daniel@0 109 /* This is the node struct allocated per graph (or subgraph). It resides
Daniel@0 110 in the n_dict of the graph. The node set is maintained by libdict, but
Daniel@0 111 transparently to libgraph callers. Every node may be given an optional
Daniel@0 112 string name at its time of creation, or it is permissible to pass NIL(char*)
Daniel@0 113 for the name. */
Daniel@0 114
Daniel@0 115 struct Agsubnode_s { /* the node-per-graph-or-subgraph record */
Daniel@0 116 Dtlink_t seq_link; /* must be first */
Daniel@0 117 Dtlink_t id_link;
Daniel@0 118 Agnode_t *node; /* the object */
Daniel@0 119 Dtlink_t *in_id, *out_id; /* by node/ID for random access */
Daniel@0 120 Dtlink_t *in_seq, *out_seq; /* by node/sequence for serial access */
Daniel@0 121 };
Daniel@0 122
Daniel@0 123 struct Agnode_s {
Daniel@0 124 Agobj_t base;
Daniel@0 125 Agraph_t *root;
Daniel@0 126 Agsubnode_t mainsub; /* embedded for main graph */
Daniel@0 127 };
Daniel@0 128
Daniel@0 129 struct Agedge_s {
Daniel@0 130 Agobj_t base;
Daniel@0 131 Dtlink_t id_link; /* main graph only */
Daniel@0 132 Dtlink_t seq_link;
Daniel@0 133 Agnode_t *node; /* the endpoint node */
Daniel@0 134 };
Daniel@0 135
Daniel@0 136 struct Agedgepair_s {
Daniel@0 137 Agedge_t out, in;
Daniel@0 138 };
Daniel@0 139
Daniel@0 140 struct Agdesc_s { /* graph descriptor */
Daniel@0 141 unsigned directed:1; /* if edges are asymmetric */
Daniel@0 142 unsigned strict:1; /* if multi-edges forbidden */
Daniel@0 143 unsigned no_loop:1; /* if no loops */
Daniel@0 144 unsigned maingraph:1; /* if this is the top level graph */
Daniel@0 145 unsigned flatlock:1; /* if sets are flattened into lists in cdt */
Daniel@0 146 unsigned no_write:1; /* if a temporary subgraph */
Daniel@0 147 unsigned has_attrs:1; /* if string attr tables should be initialized */
Daniel@0 148 unsigned has_cmpnd:1; /* if may contain collapsed nodes */
Daniel@0 149 };
Daniel@0 150
Daniel@0 151 /* disciplines for external resources needed by libgraph */
Daniel@0 152
Daniel@0 153 struct Agmemdisc_s { /* memory allocator */
Daniel@0 154 void *(*open) (void); /* independent of other resources */
Daniel@0 155 void *(*alloc) (void *state, size_t req);
Daniel@0 156 void *(*resize) (void *state, void *ptr, size_t old, size_t req);
Daniel@0 157 void (*free) (void *state, void *ptr);
Daniel@0 158 void (*close) (void *state);
Daniel@0 159 };
Daniel@0 160
Daniel@0 161 struct Agiddisc_s { /* object ID allocator */
Daniel@0 162 void *(*open) (Agraph_t * g); /* associated with a graph */
Daniel@0 163 long (*map) (void *state, int objtype, char *str, unsigned long *id,
Daniel@0 164 int createflag);
Daniel@0 165 long (*alloc) (void *state, int objtype, unsigned long id);
Daniel@0 166 void (*free) (void *state, int objtype, unsigned long id);
Daniel@0 167 char *(*print) (void *state, int objtype, unsigned long id);
Daniel@0 168 void (*close) (void *state);
Daniel@0 169 };
Daniel@0 170
Daniel@0 171 struct Agiodisc_s {
Daniel@0 172 int (*afread) (void *chan, char *buf, int bufsize);
Daniel@0 173 int (*putstr) (void *chan, const char *str);
Daniel@0 174 int (*flush) (void *chan); /* sync */
Daniel@0 175 /* error messages? */
Daniel@0 176 };
Daniel@0 177
Daniel@0 178 struct Agdisc_s { /* user's discipline */
Daniel@0 179 Agmemdisc_t *mem;
Daniel@0 180 Agiddisc_t *id;
Daniel@0 181 Agiodisc_t *io;
Daniel@0 182 };
Daniel@0 183
Daniel@0 184 /* default resource disciplines */
Daniel@0 185 #if !defined(_BLD_cgraph) && defined(GVDLL)
Daniel@0 186 #define extern __declspec(dllimport)
Daniel@0 187 #endif
Daniel@0 188
Daniel@0 189 /*visual studio*/
Daniel@0 190 #ifdef WIN32_DLL
Daniel@0 191 #ifndef CGRAPH_EXPORTS
Daniel@0 192 #define extern __declspec(dllimport)
Daniel@0 193 #endif
Daniel@0 194 #endif
Daniel@0 195 /*end visual studio*/
Daniel@0 196
Daniel@0 197 extern Agmemdisc_t AgMemDisc;
Daniel@0 198 extern Agiddisc_t AgIdDisc;
Daniel@0 199 extern Agiodisc_t AgIoDisc;
Daniel@0 200
Daniel@0 201 extern Agdisc_t AgDefaultDisc;
Daniel@0 202 #undef extern
Daniel@0 203
Daniel@0 204 struct Agdstate_s {
Daniel@0 205 void *mem;
Daniel@0 206 void *id;
Daniel@0 207 /* IO must be initialized and finalized outside Cgraph,
Daniel@0 208 * and channels (FILES) are passed as void* arguments. */
Daniel@0 209 };
Daniel@0 210
Daniel@0 211 typedef void (*agobjfn_t) (Agraph_t * g, Agobj_t * obj, void *arg);
Daniel@0 212 typedef void (*agobjupdfn_t) (Agraph_t * g, Agobj_t * obj, void *arg,
Daniel@0 213 Agsym_t * sym);
Daniel@0 214
Daniel@0 215 struct Agcbdisc_s {
Daniel@0 216 struct {
Daniel@0 217 agobjfn_t ins;
Daniel@0 218 agobjupdfn_t mod;
Daniel@0 219 agobjfn_t del;
Daniel@0 220 } graph, node, edge;
Daniel@0 221 };
Daniel@0 222
Daniel@0 223 struct Agcbstack_s { /* object event callbacks */
Daniel@0 224 Agcbdisc_t *f; /* methods */
Daniel@0 225 void *state; /* closure */
Daniel@0 226 Agcbstack_t *prev; /* kept in a stack, unlike other disciplines */
Daniel@0 227 };
Daniel@0 228
Daniel@0 229 struct Agclos_s {
Daniel@0 230 Agdisc_t disc; /* resource discipline functions */
Daniel@0 231 Agdstate_t state; /* resource closures */
Daniel@0 232 Dict_t *strdict; /* shared string dict */
Daniel@0 233 unsigned long seq[3]; /* local object sequence number counter */
Daniel@0 234 Agcbstack_t *cb; /* user and system callback function stacks */
Daniel@0 235 unsigned char callbacks_enabled; /* issue user callbacks or hold them? */
Daniel@0 236 Dict_t *lookup_by_name[3];
Daniel@0 237 Dict_t *lookup_by_id[3];
Daniel@0 238 };
Daniel@0 239
Daniel@0 240 struct Agraph_s {
Daniel@0 241 Agobj_t base;
Daniel@0 242 Agdesc_t desc;
Daniel@0 243 Dtlink_t link;
Daniel@0 244 Dict_t *n_seq; /* the node set in sequence */
Daniel@0 245 Dict_t *n_id; /* the node set indexed by ID */
Daniel@0 246 Dict_t *e_seq, *e_id; /* holders for edge sets */
Daniel@0 247 Dict_t *g_dict; /* subgraphs - descendants */
Daniel@0 248 Agraph_t *parent, *root; /* subgraphs - ancestors */
Daniel@0 249 Agclos_t *clos; /* shared resources */
Daniel@0 250 };
Daniel@0 251
Daniel@0 252
Daniel@0 253 #if _PACKAGE_ast
Daniel@0 254 /* fine control of object callbacks */
Daniel@0 255 # if defined(_BLD_cgraph) && defined(__EXPORT__)
Daniel@0 256 # define extern __EXPORT__
Daniel@0 257 # endif
Daniel@0 258 # if !defined(_BLD_cgraph) && defined(__IMPORT__)
Daniel@0 259 # define extern __IMPORT__
Daniel@0 260 # endif
Daniel@0 261 #endif
Daniel@0 262
Daniel@0 263 extern void agpushdisc(Agraph_t * g, Agcbdisc_t * disc, void *state);
Daniel@0 264 extern int agpopdisc(Agraph_t * g, Agcbdisc_t * disc);
Daniel@0 265 extern int agcallbacks(Agraph_t * g, int flag); /* return prev value */
Daniel@0 266
Daniel@0 267 /* graphs */
Daniel@0 268 extern Agraph_t *agopen(char *name, Agdesc_t desc, Agdisc_t * disc);
Daniel@0 269 extern int agclose(Agraph_t * g);
Daniel@0 270 extern Agraph_t *agread(void *chan, Agdisc_t * disc);
Daniel@0 271 extern void agreadline(int);
Daniel@0 272 extern void agsetfile(char *);
Daniel@0 273 extern Agraph_t *agconcat(Agraph_t * g, void *chan, Agdisc_t * disc);
Daniel@0 274 extern int agwrite(Agraph_t * g, void *chan);
Daniel@0 275 extern int agisdirected(Agraph_t * g);
Daniel@0 276 extern int agisundirected(Agraph_t * g);
Daniel@0 277 extern int agisstrict(Agraph_t * g);
Daniel@0 278 extern int agissimple(Agraph_t * g);
Daniel@0 279
Daniel@0 280 /* nodes */
Daniel@0 281 extern Agnode_t *agnode(Agraph_t * g, char *name, int createflag);
Daniel@0 282 extern Agnode_t *agidnode(Agraph_t * g, unsigned long id, int createflag);
Daniel@0 283 extern Agnode_t *agsubnode(Agraph_t * g, Agnode_t * n, int createflag);
Daniel@0 284 extern Agnode_t *agfstnode(Agraph_t * g);
Daniel@0 285 extern Agnode_t *agnxtnode(Agraph_t * g, Agnode_t * n);
Daniel@0 286 extern Agnode_t *aglstnode(Agraph_t * g);
Daniel@0 287 extern Agnode_t *agprvnode(Agraph_t * g, Agnode_t * n);
Daniel@0 288
Daniel@0 289 extern Agsubnode_t *agsubrep(Agraph_t * g, Agnode_t * n);
Daniel@0 290
Daniel@0 291 /* edges */
Daniel@0 292 extern Agedge_t *agedge(Agraph_t * g, Agnode_t * t, Agnode_t * h,
Daniel@0 293 char *name, int createflag);
Daniel@0 294 extern Agedge_t *agidedge(Agraph_t * g, Agnode_t * t, Agnode_t * h,
Daniel@0 295 unsigned long id, int createflag);
Daniel@0 296 extern Agedge_t *agsubedge(Agraph_t * g, Agedge_t * e, int createflag);
Daniel@0 297 extern Agedge_t *agfstin(Agraph_t * g, Agnode_t * n);
Daniel@0 298 extern Agedge_t *agnxtin(Agraph_t * g, Agedge_t * e);
Daniel@0 299 extern Agedge_t *agfstout(Agraph_t * g, Agnode_t * n);
Daniel@0 300 extern Agedge_t *agnxtout(Agraph_t * g, Agedge_t * e);
Daniel@0 301 extern Agedge_t *agfstedge(Agraph_t * g, Agnode_t * n);
Daniel@0 302 extern Agedge_t *agnxtedge(Agraph_t * g, Agedge_t * e, Agnode_t * n);
Daniel@0 303
Daniel@0 304 /* generic */
Daniel@0 305 extern Agraph_t *agraphof(void* obj);
Daniel@0 306 extern Agraph_t *agroot(void* obj);
Daniel@0 307 extern int agcontains(Agraph_t *, void *);
Daniel@0 308 extern char *agnameof(void *);
Daniel@0 309 extern int agrelabel(void *obj, char *name); /* scary */
Daniel@0 310 extern int agrelabel_node(Agnode_t * n, char *newname);
Daniel@0 311 extern int agdelete(Agraph_t * g, void *obj);
Daniel@0 312 extern long agdelsubg(Agraph_t * g, Agraph_t * sub); /* could be agclose */
Daniel@0 313 extern int agdelnode(Agraph_t * g, Agnode_t * arg_n);
Daniel@0 314 extern int agdeledge(Agraph_t * g, Agedge_t * arg_e);
Daniel@0 315 extern int agobjkind(void *);
Daniel@0 316
Daniel@0 317 /* strings */
Daniel@0 318 extern char *agstrdup(Agraph_t *, char *);
Daniel@0 319 extern char *agstrdup_html(Agraph_t *, char *);
Daniel@0 320 extern int aghtmlstr(char *);
Daniel@0 321 extern char *agstrbind(Agraph_t * g, char *);
Daniel@0 322 extern int agstrfree(Agraph_t *, char *);
Daniel@0 323 extern char *agstrcanon(char *, char *);
Daniel@0 324 char *agcanonStr(char *str); /* manages its own buf */
Daniel@0 325
Daniel@0 326 /* definitions for dynamic string attributes */
Daniel@0 327 struct Agattr_s { /* dynamic string attributes */
Daniel@0 328 Agrec_t h; /* common data header */
Daniel@0 329 Dict_t *dict; /* shared dict to interpret attr field */
Daniel@0 330 char **str; /* the attribute string values */
Daniel@0 331 };
Daniel@0 332
Daniel@0 333 struct Agsym_s { /* symbol in one of the above dictionaries */
Daniel@0 334 Dtlink_t link;
Daniel@0 335 char *name; /* attribute's name */
Daniel@0 336 char *defval; /* its default value for initialization */
Daniel@0 337 int id; /* its index in attr[] */
Daniel@0 338 unsigned char kind; /* referent object type */
Daniel@0 339 unsigned char fixed; /* immutable value */
Daniel@0 340 };
Daniel@0 341
Daniel@0 342 struct Agdatadict_s { /* set of dictionaries per graph */
Daniel@0 343 Agrec_t h; /* installed in list of graph recs */
Daniel@0 344 struct {
Daniel@0 345 Dict_t *n, *e, *g;
Daniel@0 346 } dict;
Daniel@0 347 };
Daniel@0 348
Daniel@0 349 extern Agsym_t *agattr(Agraph_t * g, int kind, char *name, char *value);
Daniel@0 350 extern Agsym_t *agattrsym(void *obj, char *name);
Daniel@0 351 extern Agsym_t *agnxtattr(Agraph_t * g, int kind, Agsym_t * attr);
Daniel@0 352 extern int agcopyattr(void *oldobj, void *newobj);
Daniel@0 353
Daniel@0 354 extern void *agbindrec(void *obj, char *name, unsigned int size,
Daniel@0 355 int move_to_front);
Daniel@0 356 extern Agrec_t *aggetrec(void *obj, char *name, int move_to_front);
Daniel@0 357 extern int agdelrec(void *obj, char *name);
Daniel@0 358 extern void aginit(Agraph_t * g, int kind, char *rec_name, int rec_size,
Daniel@0 359 int move_to_front);
Daniel@0 360 extern void agclean(Agraph_t * g, int kind, char *rec_name);
Daniel@0 361
Daniel@0 362 extern char *agget(void *obj, char *name);
Daniel@0 363 extern char *agxget(void *obj, Agsym_t * sym);
Daniel@0 364 extern int agset(void *obj, char *name, char *value);
Daniel@0 365 extern int agxset(void *obj, Agsym_t * sym, char *value);
Daniel@0 366 extern int agsafeset(void* obj, char* name, char* value, char* def);
Daniel@0 367
Daniel@0 368 /* defintions for subgraphs */
Daniel@0 369 extern Agraph_t *agsubg(Agraph_t * g, char *name, int cflag); /* constructor */
Daniel@0 370 extern Agraph_t *agidsubg(Agraph_t * g, unsigned long id, int cflag); /* constructor */
Daniel@0 371 extern Agraph_t *agfstsubg(Agraph_t * g), *agnxtsubg(Agraph_t * subg);
Daniel@0 372 extern Agraph_t *agparent(Agraph_t * g);
Daniel@0 373
Daniel@0 374 /* set cardinality */
Daniel@0 375 extern int agnnodes(Agraph_t * g), agnedges(Agraph_t * g);
Daniel@0 376 extern int agdegree(Agraph_t * g, Agnode_t * n, int in, int out);
Daniel@0 377 extern int agcountuniqedges(Agraph_t * g, Agnode_t * n, int in, int out);
Daniel@0 378
Daniel@0 379 /* memory */
Daniel@0 380 extern void *agalloc(Agraph_t * g, size_t size);
Daniel@0 381 extern void *agrealloc(Agraph_t * g, void *ptr, size_t oldsize,
Daniel@0 382 size_t size);
Daniel@0 383 extern void agfree(Agraph_t * g, void *ptr);
Daniel@0 384 extern struct _vmalloc_s *agheap(Agraph_t * g);
Daniel@0 385
Daniel@0 386 /* an engineering compromise is a joy forever */
Daniel@0 387 extern void aginternalmapclearlocalnames(Agraph_t * g);
Daniel@0 388
Daniel@0 389 #define agnew(g,t) ((t*)agalloc(g,sizeof(t)))
Daniel@0 390 #define agnnew(g,n,t) ((t*)agalloc(g,(n)*sizeof(t)))
Daniel@0 391
Daniel@0 392 /* error handling */
Daniel@0 393 typedef enum { AGWARN, AGERR, AGMAX, AGPREV } agerrlevel_t;
Daniel@0 394 extern agerrlevel_t agerrno;
Daniel@0 395 extern void agseterr(agerrlevel_t);
Daniel@0 396 extern char *aglasterr(void);
Daniel@0 397 extern int agerr(agerrlevel_t level, char *fmt, ...);
Daniel@0 398 extern void agerrorf(char *fmt, ...);
Daniel@0 399 extern void agwarningf(char *fmt, ...);
Daniel@0 400 extern int agerrors(void);
Daniel@0 401
Daniel@0 402 /* data access macros */
Daniel@0 403 /* this assumes that e[0] is out and e[1] is inedge, see edgepair in edge.c */
Daniel@0 404 #define AGIN2OUT(e) ((e)-1)
Daniel@0 405 #define AGOUT2IN(e) ((e)+1)
Daniel@0 406 #define AGOPP(e) ((AGTYPE(e)==AGINEDGE)?AGIN2OUT(e):AGOUT2IN(e))
Daniel@0 407 #define AGMKOUT(e) (AGTYPE(e) == AGOUTEDGE? (e): AGIN2OUT(e))
Daniel@0 408 #define AGMKIN(e) (AGTYPE(e) == AGINEDGE? (e): AGOUT2IN(e))
Daniel@0 409 #define AGTAIL(e) (AGMKIN(e)->node)
Daniel@0 410 #define AGHEAD(e) (AGMKOUT(e)->node)
Daniel@0 411 #define agtail(e) AGTAIL(e)
Daniel@0 412 #define aghead(e) AGHEAD(e)
Daniel@0 413 #define agopp(e) AGOPP(e)
Daniel@0 414
Daniel@0 415 #define TAILPORT_ID "tailport"
Daniel@0 416 #define HEADPORT_ID "headport"
Daniel@0 417
Daniel@0 418 #if _PACKAGE_ast
Daniel@0 419 # if !defined(_BLD_cgraph) && defined(__IMPORT__)
Daniel@0 420 # define extern __IMPORT__
Daniel@0 421 # endif
Daniel@0 422 #endif
Daniel@0 423 #if !defined(_BLD_cgraph) && defined(GVDLL)
Daniel@0 424 #define extern __declspec(dllimport)
Daniel@0 425 #endif
Daniel@0 426
Daniel@0 427 extern Agdesc_t Agdirected, Agstrictdirected, Agundirected,
Daniel@0 428 Agstrictundirected;
Daniel@0 429
Daniel@0 430 #undef extern
Daniel@0 431
Daniel@0 432 /* fast graphs */
Daniel@0 433 void agflatten(Agraph_t * g, int flag);
Daniel@0 434 typedef Agsubnode_t Agnoderef_t;
Daniel@0 435 typedef Dtlink_t Agedgeref_t;
Daniel@0 436
Daniel@0 437 #define AGHEADPOINTER(g) ((Agnoderef_t*)(g->n_seq->data->hh._head))
Daniel@0 438 #define AGRIGHTPOINTER(rep) ((Agnoderef_t*)((rep)->seq_link.right?((void*)((rep)->seq_link.right) - offsetof(Agsubnode_t,seq_link)):0))
Daniel@0 439 #define AGLEFTPOINTER(rep) ((Agnoderef_t*)((rep)->seq_link.hl._left?((void*)((rep)->seq_link.hl._left) - offsetof(Agsubnode_t,seq_link)):0))
Daniel@0 440
Daniel@0 441 #define FIRSTNREF(g) (agflatten(g,1), AGHEADPOINTER(g))
Daniel@0 442
Daniel@0 443 #define NEXTNREF(g,rep) (AGRIGHTPOINTER(rep) == AGHEADPOINTER(g)?0:AGRIGHTPOINTER(rep))
Daniel@0 444
Daniel@0 445 #define PREVNREF(g,rep) (((rep)==AGHEADPOINTER(g))?0:(AGLEFTPOINTER(rep)))
Daniel@0 446
Daniel@0 447 #define LASTNREF(g) (agflatten(g,1), AGHEADPOINTER(g)?AGLEFTPOINTER(AGHEADPOINTER(g)):0)
Daniel@0 448 #define NODEOF(rep) ((rep)->node)
Daniel@0 449
Daniel@0 450 #define FIRSTOUTREF(g,sn) (agflatten(g,1), (sn)->out_seq)
Daniel@0 451 #define LASTOUTREF(g,sn) (agflatten(g,1), (Agedgeref_t*)dtlast(sn->out_seq))
Daniel@0 452 #define FIRSTINREF(g,sn) (agflatten(g,1), (sn)->in_seq)
Daniel@0 453 #define NEXTEREF(g,rep) ((rep)->right)
Daniel@0 454 #define PREVEREF(g,rep) ((rep)->hl._left)
Daniel@0 455 /* this is expedient but a bit slimey because it "knows" that dict entries of both nodes
Daniel@0 456 and edges are embedded in main graph objects but allocated separately in subgraphs */
Daniel@0 457 #define AGSNMAIN(sn) ((sn)==(&((sn)->node->mainsub)))
Daniel@0 458 #define EDGEOF(sn,rep) (AGSNMAIN(sn)?((Agedge_t*)((unsigned char*)(rep) - offsetof(Agedge_t,seq_link))) : ((Dthold_t*)(rep))->obj)
Daniel@0 459
Daniel@0 460 #undef extern
Daniel@0 461 #if _PACKAGE_ast
Daniel@0 462 _END_EXTERNS_
Daniel@0 463 #endif
Daniel@0 464 #ifdef __cplusplus
Daniel@0 465 }
Daniel@0 466 #endif
Daniel@0 467 #endif