Graphviz 13.0.0~dev.20250402.0110
Loading...
Searching...
No Matches
cgraph.h
Go to the documentation of this file.
1
20/*************************************************************************
21 * Copyright (c) 2011 AT&T Intellectual Property
22 * All rights reserved. This program and the accompanying materials
23 * are made available under the terms of the Eclipse Public License v1.0
24 * which accompanies this distribution, and is available at
25 * https://www.eclipse.org/legal/epl-v10.html
26 *
27 * Contributors: Details at https://graphviz.org
28 *************************************************************************/
29
30#pragma once
31
32#include "cdt.h"
33#include <inttypes.h>
34#include <stdbool.h>
35#include <stddef.h>
36#include <stdint.h>
37#include <stdio.h>
38
39#ifdef __cplusplus
40extern "C" {
41#endif
42
55
56#ifdef GVDLL
57#ifdef EXPORT_CGRAPH
58#define CGRAPH_API __declspec(dllexport)
59#else
60#define CGRAPH_API __declspec(dllimport)
61#endif
62#endif
63
64#ifndef CGRAPH_API
65#define CGRAPH_API /* nothing */
66#endif
67
69
70/* forward struct type declarations */
73typedef uint64_t IDTYPE;
74typedef struct Agtag_s Agtag_t;
75typedef struct Agobj_s Agobj_t;
79typedef struct Agraph_s Agraph_t;
80typedef struct Agdesc_s Agdesc_t;
81typedef struct Agdstate_s Agdstate_t;
82typedef struct Agclos_s Agclos_t;
86typedef struct Agnode_s Agnode_t;
87typedef struct Agsubnode_s Agsubnode_t;
91typedef struct Agedge_s Agedge_t;
92typedef struct Agedgepair_s Agedgepair_t;
96typedef struct Agiddisc_s Agiddisc_t;
97typedef struct Agiodisc_s Agiodisc_t;
98typedef struct Agdisc_s Agdisc_t;
102typedef struct Agcbdisc_s Agcbdisc_t;
103typedef struct Agcbstack_s Agcbstack_t;
105
165typedef struct Agsym_s Agsym_t;
166typedef struct Agattr_s Agattr_t;
168typedef struct Agrec_s Agrec_t;
170
172struct Agrec_s {
173 char *name;
175 /* following this would be any programmer-defined data */
176};
179
197struct Agtag_s {
199 unsigned objtype : 2; /* see enum below */
200 unsigned mtflock : 1;
201 unsigned attrwf : 1; /* attrs written (parity, write.c) */
202 unsigned seq : (sizeof(unsigned) * 8 - 4); /* sequence no. */
203 IDTYPE id; /* client ID */
204};
205
208
214
215#define AGTAG(obj) (((Agobj_t *)(obj))->tag)
216#define AGTYPE(obj) (AGTAG(obj).objtype)
220#define AGID(obj) (AGTAG(obj).id)
222
223#define AGSEQ(obj) (AGTAG(obj).seq)
224#define AGATTRWF(obj) (AGTAG(obj).attrwf)
225#define AGDATA(obj) (((Agobj_t *)(obj))->data)
227
230
248struct Agsubnode_s { /* the node-per-graph-or-subgraph record */
249 Dtlink_t seq_link; /* must be first */
251 Agnode_t *node; /* the object */
252 Dtlink_t *in_id, *out_id; /* by node/ID for random access */
253 Dtlink_t *in_seq, *out_seq; /* by node/sequence for serial access */
256struct Agnode_s {
258 Agraph_t *root;
259 Agsubnode_t mainsub; /* embedded for main graph */
265struct Agedge_s {
267 Dtlink_t id_link; /* main graph only */
269 Agnode_t *node; /* the endpoint node */
273 Agedge_t out, in;
274};
279
281struct Agdesc_s { /* graph descriptor */
282 unsigned directed : 1; /* if edges are asymmetric */
283 unsigned strict : 1; /* if multi-edges forbidden */
284 unsigned no_loop : 1; /* if no loops */
285 unsigned maingraph : 1; /* if this is the top level graph */
286 unsigned no_write : 1; /* if a temporary subgraph */
287 unsigned has_attrs : 1; /* if string attr tables should be initialized */
288 unsigned has_cmpnd : 1; /* if may contain collapsed nodes */
313struct Agiddisc_s {
314 void *(*open)(Agraph_t *g, Agdisc_t *); /* associated with a graph */
315 long (*map)(void *state, int objtype, char *str, IDTYPE *id, int createflag);
316 void (*free)(void *state, int objtype, IDTYPE id);
317 char *(*print)(void *state, int objtype, IDTYPE id);
318 void (*close)(void *state);
319 void (*idregister)(void *state, int objtype, void *obj);
323struct Agiodisc_s {
324 int (*afread)(void *chan, char *buf, int bufsize);
325 int (*putstr)(void *chan, const char *str);
326 int (*flush)(void *chan); /* sync */
327 /* error messages? */
333struct Agdisc_s {
334 Agiddisc_t *id;
335 Agiodisc_t *io;
338/* default resource disciplines */
339
340CGRAPH_API extern Agiddisc_t AgIdDisc;
341CGRAPH_API extern Agiodisc_t AgIoDisc;
342
343CGRAPH_API extern Agdisc_t AgDefaultDisc;
345
359struct Agdstate_s {
360 void *id;
361 /* IO must be initialized and finalized outside Cgraph,
362 * and channels (FILES) are passed as void* arguments. */
364
365typedef void (*agobjfn_t)(Agraph_t *g, Agobj_t *obj, void *arg);
366typedef void (*agobjupdfn_t)(Agraph_t *g, Agobj_t *obj, void *arg,
367 Agsym_t *sym);
384struct Agcbdisc_s {
385 struct {
395struct Agcbstack_s {
396 Agcbdisc_t *f; /* methods */
397 void *state; /* closure */
398 Agcbstack_t *prev; /* kept in a stack, unlike other disciplines */
401CGRAPH_API void agpushdisc(Agraph_t *g, Agcbdisc_t *disc, void *state);
402CGRAPH_API int agpopdisc(Agraph_t *g, Agcbdisc_t *disc);
403
405
407struct Agclos_s {
408 Agdisc_t disc; /* resource discipline functions */
409 Agdstate_t state; /* resource closures */
410 void *strdict;
411 uint64_t seq[3]; /* local object sequence number counter */
412 Agcbstack_t *cb; /* user and system callback function stacks */
418struct graphviz_node_set;
419
421struct Agraph_s {
448CGRAPH_API int agclose(Agraph_t *g);
450CGRAPH_API Agraph_t *agread(void *chan, Agdisc_t *disc);
452
453CGRAPH_API Agraph_t *agmemread(const char *cp);
455
456CGRAPH_API Agraph_t *agmemconcat(Agraph_t *g, const char *cp);
457
458CGRAPH_API void agsetfile(const char *);
460
461CGRAPH_API Agraph_t *agconcat(Agraph_t *g, void *chan, Agdisc_t *disc);
470CGRAPH_API int agwrite(Agraph_t *g, void *chan);
471CGRAPH_API int agisdirected(Agraph_t *g);
472CGRAPH_API int agisundirected(Agraph_t *g);
473CGRAPH_API int agisstrict(Agraph_t *g);
474CGRAPH_API int agissimple(Agraph_t *g);
476
479CGRAPH_API Agnode_t *agnode(Agraph_t *g, char *name, int createflag);
480CGRAPH_API Agnode_t *agidnode(Agraph_t *g, IDTYPE id, int createflag);
481CGRAPH_API Agnode_t *agsubnode(Agraph_t *g, Agnode_t *n, int createflag);
482CGRAPH_API Agnode_t *agfstnode(Agraph_t *g);
483CGRAPH_API Agnode_t *agnxtnode(Agraph_t *g, Agnode_t *n);
484CGRAPH_API Agnode_t *aglstnode(Agraph_t *g);
485CGRAPH_API Agnode_t *agprvnode(Agraph_t *g, Agnode_t *n);
486
487CGRAPH_API Agsubnode_t *agsubrep(Agraph_t *g, Agnode_t *n);
488CGRAPH_API int agnodebefore(Agnode_t *u, Agnode_t *v); /* we have no shame */
489CGRAPH_API int agdelnode(Agraph_t *g, Agnode_t *arg_n);
491CGRAPH_API int agrelabel_node(Agnode_t *n, char *newname);
493
515CGRAPH_API Agedge_t *agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name,
516 int createflag);
517CGRAPH_API Agedge_t *agidedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, IDTYPE id,
518 int createflag);
519CGRAPH_API Agedge_t *agsubedge(Agraph_t *g, Agedge_t *e, int createflag);
520CGRAPH_API Agedge_t *agfstin(Agraph_t *g, Agnode_t *n);
521CGRAPH_API Agedge_t *agnxtin(Agraph_t *g, Agedge_t *e);
522CGRAPH_API Agedge_t *agfstout(Agraph_t *g, Agnode_t *n);
523CGRAPH_API Agedge_t *agnxtout(Agraph_t *g, Agedge_t *e);
524CGRAPH_API Agedge_t *agfstedge(Agraph_t *g, Agnode_t *n);
525CGRAPH_API Agedge_t *agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n);
526CGRAPH_API int agdeledge(Agraph_t *g, Agedge_t *arg_e);
528
531
532// Generic object (graphs, nodes and edges) functions
533
534CGRAPH_API Agraph_t *agraphof(void *obj);
535CGRAPH_API Agraph_t *agroot(void *obj);
538
539CGRAPH_API int agcontains(Agraph_t *, void *obj);
541
542CGRAPH_API char *agnameof(void *);
544
545CGRAPH_API int agdelete(Agraph_t *g, void *obj);
552CGRAPH_API int agobjkind(void *obj);
556
579CGRAPH_API char *agstrdup(Agraph_t *, const char *);
587
588CGRAPH_API char *agstrdup_text(Agraph_t *, const char *);
591
592CGRAPH_API char *agstrdup_html(Agraph_t *, const char *);
595
596CGRAPH_API int aghtmlstr(const char *);
599CGRAPH_API char *agstrbind(Agraph_t *g, const char *);
602CGRAPH_API char *agstrbind_text(Agraph_t *g, const char *);
605CGRAPH_API char *agstrbind_html(Agraph_t *g, const char *);
608
609CGRAPH_API int agstrfree(Agraph_t *, const char *, bool is_html);
611CGRAPH_API char *agstrcanon(char *, char *);
612CGRAPH_API char *agcanonStr(char *str); /* manages its own buf */
614
637// definitions for dynamic string attributes
638
640struct Agattr_s { /* dynamic string attributes */
641 Agrec_t h; /* common data header */
642 Dict_t *dict;
643 char **str;
648struct Agsym_s {
650 char *name; /* attribute's name */
651 char *defval; /* its default value for initialization */
652 int id;
653 unsigned char kind; /* referent object type */
654 unsigned char fixed; /* immutable value */
655 unsigned char print; /* always print */
659 Agrec_t h; /* installed in list of graph recs */
660 struct {
661 Dict_t *n, *e, *g;
663};
665CGRAPH_API Agsym_t *agattr_text(Agraph_t *g, int kind, char *name,
666 const char *value);
685CGRAPH_API Agsym_t *agattr_html(Agraph_t *g, int kind, char *name,
686 const char *value);
702
703CGRAPH_API Agsym_t *agattr(Agraph_t *g, int kind, char *name,
704 const char *value);
723
724CGRAPH_API Agsym_t *agattrsym(void *obj, char *name);
726
727CGRAPH_API Agsym_t *agnxtattr(Agraph_t *g, int kind, Agsym_t *attr);
731
732CGRAPH_API int agcopyattr(void *oldobj, void *newobj);
741CGRAPH_API void *agbindrec(void *obj, const char *name, unsigned int recsize,
742 int move_to_front);
746
747CGRAPH_API Agrec_t *aggetrec(void *obj, const char *name, int move_to_front);
749
750CGRAPH_API int agdelrec(void *obj, const char *name);
752
753CGRAPH_API void aginit(Agraph_t *g, int kind, const char *rec_name,
754 int rec_size, int move_to_front);
762CGRAPH_API void agclean(Agraph_t *g, int kind, char *rec_name);
765
767
768CGRAPH_API char *agget(void *obj, char *name);
769CGRAPH_API char *agxget(void *obj, Agsym_t *sym);
770CGRAPH_API int agset(void *obj, char *name, const char *value);
771CGRAPH_API int agset_text(void *obj, char *name, const char *value);
772CGRAPH_API int agset_html(void *obj, char *name, const char *value);
773CGRAPH_API int agxset(void *obj, Agsym_t *sym, const char *value);
774CGRAPH_API int agxset_text(void *obj, Agsym_t *sym, const char *value);
775CGRAPH_API int agxset_html(void *obj, Agsym_t *sym, const char *value);
776
777CGRAPH_API int agsafeset_text(void *obj, char *name, const char *value,
778 const char *def);
789
790CGRAPH_API int agsafeset_html(void *obj, char *name, const char *value,
791 const char *def);
802
803CGRAPH_API int agsafeset(void *obj, char *name, const char *value,
804 const char *def);
832
834
862CGRAPH_API Agraph_t *agsubg(Agraph_t *g, char *name,
863 int cflag); /* constructor */
864CGRAPH_API Agraph_t *agidsubg(Agraph_t *g, IDTYPE id);
865CGRAPH_API Agraph_t *agfstsubg(Agraph_t *g);
866CGRAPH_API Agraph_t *agnxtsubg(Agraph_t *subg);
867CGRAPH_API Agraph_t *agparent(Agraph_t *g);
868CGRAPH_API int agdelsubg(Agraph_t *g, Agraph_t *sub); /* could be agclose */
870
894CGRAPH_API int agnnodes(Agraph_t *g);
895CGRAPH_API int agnedges(Agraph_t *g);
896CGRAPH_API int agnsubg(Agraph_t *g);
897CGRAPH_API int agdegree(Agraph_t *g, Agnode_t *n, int in, int out);
898CGRAPH_API int agcountuniqedges(Agraph_t *g, Agnode_t *n, int in, int out);
900
903/* an engineering compromise is a joy forever */
904CGRAPH_API void aginternalmapclearlocalnames(Agraph_t *g);
906
908
909/* support for extra API misuse warnings if available */
910#ifdef __GNUC__
911#define PRINTF_LIKE(index, first) __attribute__((format(printf, index, first)))
912#else
913#define PRINTF_LIKE(index, first) /* nothing */
914#endif
915
917
958typedef enum { AGWARN, AGERR, AGMAX, AGPREV } agerrlevel_t;
959typedef int (*agusererrf)(char *);
961CGRAPH_API char *aglasterr(void);
962CGRAPH_API int agerr(agerrlevel_t level, const char *fmt, ...)
963 PRINTF_LIKE(2, 3);
964CGRAPH_API void agerrorf(const char *fmt, ...) PRINTF_LIKE(1, 2);
965CGRAPH_API void agwarningf(const char *fmt, ...) PRINTF_LIKE(1, 2);
966CGRAPH_API int agerrors(void);
967CGRAPH_API int agreseterrors(void);
970
971#undef PRINTF_LIKE
973
976/* data access macros */
977/* this assumes that e[0] is out and e[1] is inedge, see @ref Agedgepair_s */
978#define AGIN2OUT(inedge) ((inedge) - 1)
979#define AGOUT2IN(outedge) \
980 ((outedge) + 1)
981#define AGOPP(e) ((AGTYPE(e) == AGINEDGE) ? AGIN2OUT(e) : AGOUT2IN(e))
982#define AGMKOUT(e) (AGTYPE(e) == AGOUTEDGE ? (e) : AGIN2OUT(e))
983#define AGMKIN(e) (AGTYPE(e) == AGINEDGE ? (e) : AGOUT2IN(e))
984#define AGTAIL(e) (AGMKIN(e)->node)
985#define AGHEAD(e) (AGMKOUT(e)->node)
986#define AGEQEDGE(e, f) (AGMKOUT(e) == AGMKOUT(f))
987/* These macros are also exposed as functions, so they can be linked against. */
988#define agtail(e) AGTAIL(e)
989#define aghead(e) AGHEAD(e)
990#define agopp(e) \
991 AGOPP(e)
992#define ageqedge(e, f) AGEQEDGE(e, f)
994#define TAILPORT_ID "tailport"
995#define HEADPORT_ID "headport"
1000CGRAPH_API extern Agdesc_t Agdirected;
1001CGRAPH_API extern Agdesc_t Agstrictdirected;
1003CGRAPH_API extern Agdesc_t Agundirected;
1004CGRAPH_API extern Agdesc_t Agstrictundirected;
1006
1012/* this is expedient but a bit slimey because it "knows" that dict entries of
1013both nodes and edges are embedded in main graph objects but allocated separately
1014in subgraphs */
1015#define AGSNMAIN(sn) ((sn) == (&((sn)->node->mainsub)))
1017
1022typedef struct {
1023 FILE *outFile;
1024 bool doWrite;
1025 bool Verbose;
1036CGRAPH_API bool graphviz_acyclic(Agraph_t *g,
1038 size_t *num_rev);
1039
1041typedef struct {
1042 bool Verbose;
1043 bool PrintRemovedEdges;
1044 FILE *out;
1045 FILE *err;
1055CGRAPH_API void graphviz_tred(Agraph_t *g, const graphviz_tred_options_t *opts);
1056
1058typedef struct {
1059 bool Do_fans;
1060 int MaxMinlen;
1061 int ChainLimit;
1070CGRAPH_API void graphviz_unflatten(Agraph_t *g,
1072
1086CGRAPH_API size_t graphviz_node_induce(Agraph_t *g, Agraph_t *edgeset);
1088
1089#ifdef __cplusplus
1090}
1091#endif
static void out(agerrlevel_t level, const char *fmt, va_list args)
Report messages using a user-supplied or default write function.
Definition agerror.c:84
container data types API
#define sub(h, i)
Definition closest.c:67
static FILE * outFile
Definition cvtgxl.c:35
static char * err
Definition delaunay.c:696
#define PRINTF_LIKE(index, first)
Definition error.h:48
static Dtdisc_t disc
Definition exparse.y:207
static bool Verbose
Definition gml2gv.c:23
int agnsubg(Agraph_t *g)
Definition graph.c:175
int agcountuniqedges(Agraph_t *g, Agnode_t *n, int in, int out)
Definition graph.c:209
int agnedges(Agraph_t *g)
Definition graph.c:165
int agdegree(Agraph_t *g, Agnode_t *n, int in, int out)
Definition graph.c:227
int agnnodes(Agraph_t *g)
Definition graph.c:159
void aginternalmapclearlocalnames(Agraph_t *g)
Definition imap.c:165
bool graphviz_acyclic(Agraph_t *g, const graphviz_acyclic_options_t *opts, size_t *num_rev)
Definition acyclic.c:86
void graphviz_unflatten(Agraph_t *g, const graphviz_unflatten_options_t *opts)
Definition unflatten.c:56
size_t graphviz_node_induce(Agraph_t *g, Agraph_t *edgeset)
Definition node_induce.c:9
void graphviz_tred(Agraph_t *g, const graphviz_tred_options_t *opts)
programmatic access to tred - transitive reduction
Definition tred.c:183
int agsafeset_html(void *obj, char *name, const char *value, const char *def)
set an attribute’s value and default, ensuring it is declared before setting it locally
Definition attr.c:578
Agsym_t * agattr_text(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up text attributes of a graph
Definition attr.c:357
Agsym_t * agattrsym(void *obj, char *name)
looks up a string attribute for a graph object given as an argument
Definition attr.c:154
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up an attribute, without specifying desired form
Definition attr.c:365
int agset(void *obj, char *name, const char *value)
Definition attr.c:499
Agsym_t * agnxtattr(Agraph_t *g, int kind, Agsym_t *attr)
permits traversing the list of attributes of a given type
Definition attr.c:386
int agxset(void *obj, Agsym_t *sym, const char *value)
Definition attr.c:546
int agxset_html(void *obj, Agsym_t *sym, const char *value)
Definition attr.c:565
char * agget(void *obj, char *name)
Definition attr.c:472
int agsafeset(void *obj, char *name, const char *value, const char *def)
set an attribute’s value and default, ensuring it is declared before setting it locally
Definition attr.c:586
int agset_html(void *obj, char *name, const char *value)
Definition attr.c:518
int agset_text(void *obj, char *name, const char *value)
Definition attr.c:514
char * agxget(void *obj, Agsym_t *sym)
Definition attr.c:482
int agcopyattr(void *oldobj, void *newobj)
copies all of the attributes from one object to another
Definition attr.c:659
int agsafeset_text(void *obj, char *name, const char *value, const char *def)
set an attribute’s value and default, ensuring it is declared before setting it locally
Definition attr.c:569
Agsym_t * agattr_html(Agraph_t *g, int kind, char *name, const char *value)
agattr_text, but creates HTML-like values
Definition attr.c:361
int agxset_text(void *obj, Agsym_t *sym, const char *value)
Definition attr.c:561
int agpopdisc(Agraph_t *g, Agcbdisc_t *disc)
Definition obj.c:211
void agpushdisc(Agraph_t *g, Agcbdisc_t *disc, void *state)
Definition obj.c:202
Agdisc_t AgDefaultDisc
Definition graph.c:279
Agiddisc_t AgIdDisc
Definition id.c:91
Agiodisc_t AgIoDisc
Definition io.c:39
Agedge_t * agedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, char *name, int createflag)
Definition edge.c:256
Agedge_t * agidedge(Agraph_t *g, Agnode_t *t, Agnode_t *h, IDTYPE id, int createflag)
Definition edge.c:238
Agedge_t * agsubedge(Agraph_t *g, Agedge_t *e, int createflag)
Definition edge.c:351
int agdeledge(Agraph_t *g, Agedge_t *arg_e)
Definition edge.c:330
Agedge_t * agnxtin(Agraph_t *g, Agedge_t *e)
Definition edge.c:69
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Definition edge.c:24
Agedge_t * agnxtedge(Agraph_t *g, Agedge_t *e, Agnode_t *n)
Definition edge.c:94
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Definition edge.c:39
Agedge_t * agfstedge(Agraph_t *g, Agnode_t *n)
Definition edge.c:85
Agedge_t * agfstin(Agraph_t *g, Agnode_t *n)
Definition edge.c:55
agerrlevel_t
Definition cgraph.h:961
int agreseterrors(void)
Definition agerror.c:183
void agwarningf(const char *fmt,...)
Definition agerror.c:173
void agerrorf(const char *fmt,...)
Definition agerror.c:165
agerrlevel_t agseterr(agerrlevel_t)
Definition agerror.c:38
char * aglasterr(void)
Definition agerror.c:44
agusererrf agseterrf(agusererrf)
Definition agerror.c:32
int agerr(agerrlevel_t level, const char *fmt,...)
Definition agerror.c:155
int agerrors(void)
Definition agerror.c:181
int(* agusererrf)(char *)
Definition cgraph.h:962
@ AGWARN
Definition cgraph.h:961
@ AGMAX
Definition cgraph.h:961
@ AGERR
Definition cgraph.h:961
@ AGPREV
Definition cgraph.h:961
void(* agobjupdfn_t)(Agraph_t *g, Agobj_t *obj, void *arg, Agsym_t *sym)
Definition cgraph.h:369
void(* agobjfn_t)(Agraph_t *g, Agobj_t *obj, void *arg)
Definition cgraph.h:368
Agdesc_t Agundirected
undirected
Definition graph.c:276
int agisdirected(Agraph_t *g)
Definition graph.c:180
Agdesc_t Agstrictundirected
strict undirected
Definition graph.c:277
int agclose(Agraph_t *g)
deletes a graph, freeing its associated storage
Definition graph.c:97
int agisstrict(Agraph_t *g)
Definition graph.c:190
int agissimple(Agraph_t *g)
Definition graph.c:195
Agdesc_t Agstrictdirected
strict directed. A strict graph cannot have multi-edges or self-arcs.
Definition graph.c:275
Agraph_t * agmemconcat(Agraph_t *g, const char *cp)
Definition io.c:102
Agraph_t * agconcat(Agraph_t *g, void *chan, Agdisc_t *disc)
merges the file contents with a pre-existing graph
Definition grammar.c:2288
Agraph_t * agmemread(const char *cp)
reads a graph from the input string
Definition io.c:97
Agraph_t * agopen(char *name, Agdesc_t desc, Agdisc_t *disc)
creates a new graph with the given name and kind
Definition graph.c:44
int agisundirected(Agraph_t *g)
Definition graph.c:185
int agwrite(Agraph_t *g, void *chan)
Return 0 on success, EOF on failure.
Definition write.c:693
void agsetfile(const char *)
sets the current file name for subsequent error reporting
Definition scan.c:2415
Agraph_t * agread(void *chan, Agdisc_t *disc)
constructs a new graph
Definition grammar.c:2300
Agdesc_t Agdirected
directed
Definition graph.c:274
Agnode_t * agnode(Agraph_t *g, char *name, int createflag)
Definition node.c:140
int agnodebefore(Agnode_t *u, Agnode_t *v)
Definition node.c:327
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition node.c:47
Agnode_t * agprvnode(Agraph_t *g, Agnode_t *n)
Definition node.c:62
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:40
Agnode_t * agsubnode(Agraph_t *g, Agnode_t *n, int createflag)
Definition node.c:254
Agnode_t * agidnode(Agraph_t *g, IDTYPE id, int createflag)
Definition node.c:122
Agnode_t * aglstnode(Agraph_t *g)
Definition node.c:55
int agrelabel_node(Agnode_t *n, char *newname)
Definition node.c:232
int agdelnode(Agraph_t *g, Agnode_t *arg_n)
removes a node from a graph or subgraph.
Definition node.c:190
Agsubnode_t * agsubrep(Agraph_t *g, Agnode_t *n)
Definition edge.c:145
Agraph_t * agraphof(void *obj)
Definition obj.c:185
char * agnameof(void *)
returns a string descriptor for the object.
Definition id.c:143
uint64_t IDTYPE
unique per main graph ID
Definition cgraph.h:73
int agdelete(Agraph_t *g, void *obj)
deletes object. Equivalent to agclose, agdelnode, and agdeledge for obj being a graph,...
Definition obj.c:20
int agcontains(Agraph_t *, void *obj)
returns non-zero if obj is a member of (sub)graph
Definition obj.c:233
int agobjkind(void *obj)
Definition obj.c:252
Agraph_t * agroot(void *obj)
Definition obj.c:168
@ AGOUTEDGE
Definition cgraph.h:207
@ AGEDGE
Definition cgraph.h:207
@ AGNODE
Definition cgraph.h:207
@ AGINEDGE
Definition cgraph.h:207
@ AGRAPH
Definition cgraph.h:207
Agrec_t * aggetrec(void *obj, const char *name, int move_to_front)
find record in circular list and do optional move-to-front and lock
Definition rec.c:41
void aginit(Agraph_t *g, int kind, const char *rec_name, int rec_size, int move_to_front)
attach new records to objects of specified kind
Definition rec.c:170
void * agbindrec(void *obj, const char *name, unsigned int recsize, int move_to_front)
attaches a new record of the given size to the object
Definition rec.c:89
void agclean(Agraph_t *g, int kind, char *rec_name)
calls agdelrec for all objects of the same class in an entire graph
Definition rec.c:202
int agdelrec(void *obj, const char *name)
deletes a named record from one object
Definition rec.c:137
char * agstrbind_html(Agraph_t *g, const char *)
Definition refstr.c:352
char * agstrbind_text(Agraph_t *g, const char *)
Definition refstr.c:356
int aghtmlstr(const char *)
Definition refstr.c:436
char * agstrcanon(char *, char *)
Definition write.c:219
int agstrfree(Agraph_t *, const char *, bool is_html)
Definition refstr.c:413
char * agstrdup_text(Agraph_t *, const char *)
returns a pointer to a reference-counted regular text copy of the argument string,...
Definition refstr.c:389
char * agstrdup(Agraph_t *, const char *)
returns a pointer to a reference-counted copy of the argument string, creating one if necessary
Definition refstr.c:397
char * agstrbind(Agraph_t *g, const char *)
Definition refstr.c:337
char * agcanonStr(char *str)
Definition write.c:249
char * agstrdup_html(Agraph_t *, const char *)
returns a pointer to a reference-counted HTML-like copy of the argument string, creating one if neces...
Definition refstr.c:393
Agraph_t * agparent(Agraph_t *g)
Definition subg.c:88
Agraph_t * agidsubg(Agraph_t *g, IDTYPE id)
constructor
Definition subg.c:49
Agraph_t * agfstsubg(Agraph_t *g)
Definition subg.c:75
Agraph_t * agnxtsubg(Agraph_t *subg)
Definition subg.c:80
Agraph_t * agsubg(Agraph_t *g, char *name, int cflag)
Definition subg.c:55
int agdelsubg(Agraph_t *g, Agraph_t *sub)
Definition subg.c:96
static uint64_t id
Definition gv2gml.c:41
static opts_t opts
Definition gvgen.c:401
textitem scanner parser str
Definition htmlparse.y:224
string attribute container
Definition cgraph.h:643
char ** str
the attribute string values indexed by Agsym_s.id
Definition cgraph.h:646
Dict_t * dict
shared dict of Agsym_s to interpret Agattr_s.str
Definition cgraph.h:645
Agrec_t h
Definition cgraph.h:644
client event callbacks, used in Agcbstack_s
Definition cgraph.h:387
agobjupdfn_t mod
Definition cgraph.h:390
agobjfn_t ins
Definition cgraph.h:389
struct Agcbdisc_s::@64 edge
struct Agcbdisc_s::@64 graph
struct Agcbdisc_s::@64 node
agobjfn_t del
Definition cgraph.h:391
object event callbacks
Definition cgraph.h:398
void * state
Definition cgraph.h:400
Agcbdisc_t * f
Definition cgraph.h:399
Agcbstack_t * prev
Definition cgraph.h:401
shared resources for Agraph_s
Definition cgraph.h:410
Dict_t * lookup_by_id[3]
Definition cgraph.h:417
Agdisc_t disc
Definition cgraph.h:411
Agdstate_t state
Definition cgraph.h:412
Dict_t * lookup_by_name[3]
Definition cgraph.h:416
Agcbstack_t * cb
Definition cgraph.h:415
void * strdict
shared string dict
Definition cgraph.h:413
uint64_t seq[3]
Definition cgraph.h:414
Dict_t * n
Definition cgraph.h:664
Dict_t * e
Definition cgraph.h:664
Dict_t * g
Definition cgraph.h:664
struct Agdatadict_s::@65 dict
Agrec_t h
< set of dictionaries per graph
Definition cgraph.h:662
graph descriptor
Definition cgraph.h:284
unsigned has_attrs
Definition cgraph.h:290
unsigned maingraph
Definition cgraph.h:288
unsigned no_loop
Definition cgraph.h:287
unsigned strict
Definition cgraph.h:286
unsigned no_write
Definition cgraph.h:289
unsigned has_cmpnd
Definition cgraph.h:291
unsigned directed
Definition cgraph.h:285
user's discipline
Definition cgraph.h:336
Agiddisc_t * id
Definition cgraph.h:337
Agiodisc_t * io
Definition cgraph.h:338
client state (closures)
Definition cgraph.h:362
void * id
Definition cgraph.h:363
Dtlink_t seq_link
Definition cgraph.h:271
Agnode_t * node
Definition cgraph.h:272
Agobj_t base
Definition cgraph.h:269
Dtlink_t id_link
Definition cgraph.h:270
Agedge_t in
Definition cgraph.h:276
Agedge_t out
Definition cgraph.h:276
object ID allocator discipline
Definition cgraph.h:316
long(* map)(void *state, int objtype, char *str, IDTYPE *id, int createflag)
Definition cgraph.h:318
void(* idregister)(void *state, int objtype, void *obj)
Definition cgraph.h:322
void(* close)(void *state)
Definition cgraph.h:321
void(* free)(void *state, int objtype, IDTYPE id)
Definition cgraph.h:319
IO services.
Definition cgraph.h:326
int(* afread)(void *chan, char *buf, int bufsize)
Definition cgraph.h:327
int(* flush)(void *chan)
Definition cgraph.h:329
int(* putstr)(void *chan, const char *str)
Definition cgraph.h:328
Agsubnode_t mainsub
Definition cgraph.h:262
Agraph_t * root
Definition cgraph.h:261
Agobj_t base
Definition cgraph.h:260
a generic header of Agraph_s, Agnode_s and Agedge_s
Definition cgraph.h:210
Agrec_t * data
stores programmer-defined data, access with AGDATA
Definition cgraph.h:212
Agtag_t tag
access with AGTAG
Definition cgraph.h:211
graph or subgraph
Definition cgraph.h:424
struct graphviz_node_set * n_id
the node set indexed by ID
Definition cgraph.h:430
Dict_t * g_seq
Definition cgraph.h:432
Agraph_t * root
subgraphs - ancestors
Definition cgraph.h:433
Dtlink_t seq_link
Definition cgraph.h:427
Dict_t * g_id
subgraphs - descendants
Definition cgraph.h:432
Agobj_t base
Definition cgraph.h:425
Dict_t * e_seq
Definition cgraph.h:431
Dict_t * n_seq
the node set in sequence
Definition cgraph.h:429
Agclos_t * clos
shared resources
Definition cgraph.h:434
Agraph_t * parent
Definition cgraph.h:433
Agdesc_t desc
Definition cgraph.h:426
Dtlink_t id_link
Definition cgraph.h:428
Dict_t * e_id
holders for edge sets
Definition cgraph.h:431
implementation of Agrec_t
Definition cgraph.h:172
Agrec_t * next
circular linked list of records
Definition cgraph.h:174
char * name
Definition cgraph.h:173
This is the node struct allocated per graph (or subgraph).
Definition cgraph.h:251
Dtlink_t * out_seq
Definition cgraph.h:256
Dtlink_t * out_id
Definition cgraph.h:255
Dtlink_t seq_link
Definition cgraph.h:252
Dtlink_t * in_id
Definition cgraph.h:255
Dtlink_t id_link
Definition cgraph.h:253
Agnode_t * node
Definition cgraph.h:254
Dtlink_t * in_seq
Definition cgraph.h:256
string attribute descriptor symbol in Agattr_s.dict
Definition cgraph.h:651
Dtlink_t link
Definition cgraph.h:652
char * name
Definition cgraph.h:653
unsigned char kind
Definition cgraph.h:656
int id
index in Agattr_s.str
Definition cgraph.h:655
unsigned char fixed
Definition cgraph.h:657
char * defval
Definition cgraph.h:654
unsigned char print
Definition cgraph.h:658
tag in Agobj_s for graphs, nodes, and edges.
Definition cgraph.h:197
unsigned attrwf
Definition cgraph.h:201
unsigned objtype
access with AGTYPE
Definition cgraph.h:199
unsigned seq
Definition cgraph.h:202
unsigned mtflock
move-to-front lock, guards Agobj_s::data
Definition cgraph.h:200
IDTYPE id
Definition cgraph.h:203
Definition cdt.h:100
options for passing to graphviz_acyclic
Definition cgraph.h:1027
options for passing to graphviz_tred
Definition cgraph.h:1046
options for passing to graphviz_unflatten
Definition cgraph.h:1063