Graphviz 13.0.0~dev.20250121.0651
Loading...
Searching...
No Matches
attr.c
Go to the documentation of this file.
1
7 /*************************************************************************
8 * Copyright (c) 2011 AT&T Intellectual Property
9 * All rights reserved. This program and the accompanying materials
10 * are made available under the terms of the Eclipse Public License v1.0
11 * which accompanies this distribution, and is available at
12 * https://www.eclipse.org/legal/epl-v10.html
13 *
14 * Contributors: Details at https://graphviz.org
15 *************************************************************************/
16
17#include <cgraph/cghdr.h>
18#include <stdbool.h>
19#include <stdlib.h>
20#include <util/alloc.h>
21#include <util/streq.h>
22#include <util/unreachable.h>
23
24/*
25 * dynamic attributes
26 */
27
28/* to create a graph's data dictionary */
29
30#define MINATTR 4 /* minimum allocation */
31
32static void freesym(void *obj);
33
35 (int) offsetof(Agsym_t, name), /* use symbol name as key */
36 -1,
37 (int) offsetof(Agsym_t, link),
38 NULL,
39 freesym,
40 NULL,
41};
42
43static char DataDictName[] = "_AG_datadict";
44static void init_all_attrs(Agraph_t * g);
45static Agdesc_t ProtoDesc = {.directed = true, .no_loop = true,
46 .no_write = true};
48
51 if (rv || !cflag)
52 return rv;
54 rv = (Agdatadict_t *) aggetrec(g, DataDictName, 0);
55 return rv;
56}
57
58static Dict_t *agdictof(Agraph_t * g, int kind)
59{
60 Agdatadict_t *dd;
61 Dict_t *dict;
62
63 dd = agdatadict(g, false);
64 if (dd)
65 switch (kind) {
66 case AGRAPH:
67 dict = dd->dict.g;
68 break;
69 case AGNODE:
70 dict = dd->dict.n;
71 break;
72 case AGINEDGE:
73 case AGOUTEDGE:
74 dict = dd->dict.e;
75 break;
76 default:
77 agerrorf("agdictof: unknown kind %d\n", kind);
78 dict = NULL;
79 break;
80 } else
81 dict = NULL;
82 return dict;
83}
84
86static Agsym_t *agnewsym(Agraph_t * g, const char *name, const char *value,
87 bool is_html, int id, int kind) {
88 Agsym_t *sym = gv_alloc(sizeof(Agsym_t));
89 sym->kind = (unsigned char) kind;
90 sym->name = agstrdup(g, name);
91 sym->defval = is_html ? agstrdup_html(g, value) : agstrdup(g, value);
92 sym->id = id;
93 return sym;
94}
95
96static void agcopydict(Dict_t * src, Dict_t * dest, Agraph_t * g, int kind)
97{
98 Agsym_t *sym, *newsym;
99
100 assert(dtsize(dest) == 0);
101 for (sym = dtfirst(src); sym; sym = dtnext(src, sym)) {
102 const bool is_html = aghtmlstr(sym->defval);
103 newsym = agnewsym(g, sym->name, sym->defval, is_html, sym->id, kind);
104 newsym->print = sym->print;
105 newsym->fixed = sym->fixed;
106 dtinsert(dest, newsym);
107 }
108}
109
111{
112 Agraph_t *par;
113 Agdatadict_t *parent_dd, *dd;
114
115 dd = agbindrec(g, DataDictName, sizeof(Agdatadict_t), false);
119 if ((par = agparent(g))) {
120 parent_dd = agdatadict(par, false);
121 assert(dd != parent_dd);
122 dtview(dd->dict.n, parent_dd->dict.n);
123 dtview(dd->dict.e, parent_dd->dict.e);
124 dtview(dd->dict.g, parent_dd->dict.g);
125 } else {
126 if (ProtoGraph && g != ProtoGraph) {
127 /* it's not ok to dtview here for several reasons. the proto
128 graph could change, and the sym indices don't match */
129 parent_dd = agdatadict(ProtoGraph, false);
130 agcopydict(parent_dd->dict.n, dd->dict.n, g, AGNODE);
131 agcopydict(parent_dd->dict.e, dd->dict.e, g, AGEDGE);
132 agcopydict(parent_dd->dict.g, dd->dict.g, g, AGRAPH);
133 }
134 }
135 return dd;
136}
137
138/* look up an attribute with possible viewpathing */
139static Agsym_t *agdictsym(Dict_t * dict, char *name)
140{
141 Agsym_t key;
142 key.name = name;
143 return dtsearch(dict, &key);
144}
145
146/* look up attribute in local dictionary with no view pathing */
147static Agsym_t *aglocaldictsym(Dict_t * dict, char *name)
148{
149 Agsym_t *rv;
150 Dict_t *view;
151
152 view = dtview(dict, NULL);
153 rv = agdictsym(dict, name);
154 dtview(dict, view);
155 return rv;
156}
157
158Agsym_t *agattrsym(void *obj, char *name)
159{
160 Agattr_t *data;
161 Agsym_t *rv;
162
163 data = agattrrec(obj);
164 if (data)
165 rv = agdictsym(data->dict, name);
166 else
167 rv = NULL;
168 return rv;
169}
170
171/* to create a graph's, node's edge's string attributes */
172
173char *AgDataRecName = "_AG_strdata";
174
175static int topdictsize(Agobj_t * obj)
176{
177 Dict_t *d;
178
179 d = agdictof(agroot(agraphof(obj)), AGTYPE(obj));
180 return d ? dtsize(d) : 0;
181}
182
183/* g can be either the enclosing graph, or ProtoGraph */
184static Agrec_t *agmakeattrs(Agraph_t * context, void *obj)
185{
186 int sz;
187 Agattr_t *rec;
188 Agsym_t *sym;
189 Dict_t *datadict;
190
191 rec = agbindrec(obj, AgDataRecName, sizeof(Agattr_t), false);
192 datadict = agdictof(context, AGTYPE(obj));
193 assert(datadict);
194 if (rec->dict == NULL) {
195 rec->dict = agdictof(agroot(context), AGTYPE(obj));
196 /* don't malloc(0) */
197 sz = topdictsize(obj);
198 if (sz < MINATTR)
199 sz = MINATTR;
200 rec->str = gv_calloc((size_t)sz, sizeof(char *));
201 /* doesn't call agxset() so no obj-modified callbacks occur */
202 for (sym = dtfirst(datadict); sym; sym = dtnext(datadict, sym)) {
203 if (aghtmlstr(sym->defval)) {
204 rec->str[sym->id] = agstrdup_html(agraphof(obj), sym->defval);
205 } else {
206 rec->str[sym->id] = agstrdup(agraphof(obj), sym->defval);
207 }
208 }
209 } else {
210 assert(rec->dict == datadict);
211 }
212 return (Agrec_t *) rec;
213}
214
215static void freeattr(Agobj_t * obj, Agattr_t * attr)
216{
217 int i, sz;
218 Agraph_t *g;
219
220 g = agraphof(obj);
221 sz = topdictsize(obj);
222 for (i = 0; i < sz; i++)
223 agstrfree(g, attr->str[i], aghtmlstr(attr->str[i]));
224 free(attr->str);
225}
226
227static void freesym(void *obj) {
228 Agsym_t *sym;
229
230 sym = obj;
231 agstrfree(Ag_G_global, sym->name, false);
233 free(sym);
234}
235
237{
238 return (Agattr_t *)aggetrec(obj, AgDataRecName, 0);
239}
240
241
242static void addattr(Agraph_t * g, Agobj_t * obj, Agsym_t * sym)
243{
244 Agattr_t *attr = agattrrec(obj);
245 assert(attr != NULL);
246 if (sym->id >= MINATTR)
247 attr->str = gv_recalloc(attr->str, (size_t)sym->id, (size_t)sym->id + 1,
248 sizeof(char *));
249 if (aghtmlstr(sym->defval)) {
250 attr->str[sym->id] = agstrdup_html(g, sym->defval);
251 } else {
252 attr->str[sym->id] = agstrdup(g, sym->defval);
253 }
254}
255
256static Agsym_t *getattr(Agraph_t *g, int kind, char *name) {
257 Agsym_t *rv = 0;
258 Dict_t *dict;
259 dict = agdictof(g, kind);
260 if (dict) {
261 rv = agdictsym(dict, name); // viewpath up to root
262 }
263 return rv;
264}
265
266static void unviewsubgraphsattr(Agraph_t *parent, char *name) {
267 Agraph_t *subg;
268 Agsym_t *psym, *lsym;
269 Dict_t *ldict;
270
271 psym = getattr(parent, AGRAPH, name);
272 if (!psym) {
273 return; // supposedly can't happen, see setattr()
274 }
275 for (subg = agfstsubg(parent); subg; subg = agnxtsubg(subg)) {
276 ldict = agdatadict(subg, true)->dict.g;
277 lsym = aglocaldictsym(ldict, name);
278 if (lsym) {
279 continue;
280 }
281 char *const value = agxget(subg, psym);
282 const bool is_html = aghtmlstr(value);
283 lsym = agnewsym(agroot(subg), name, value, is_html, psym->id, AGRAPH);
284 dtinsert(ldict, lsym);
285 }
286}
287
288static int agxset_(void *obj, Agsym_t *sym, const char *value, bool is_html);
289
291static Agsym_t *setattr(Agraph_t * g, int kind, char *name, const char *value,
292 bool is_html) {
293 Dict_t *ldict, *rdict;
294 Agsym_t *lsym, *psym, *rsym, *rv;
295 Agraph_t *root;
296 Agnode_t *n;
297 Agedge_t *e;
298
299 assert(value);
300 root = agroot(g);
301 agdatadict(g, true); /* force initialization of string attributes */
302 ldict = agdictof(g, kind);
303 lsym = aglocaldictsym(ldict, name);
304 if (lsym) { /* update old local definition */
305 if (g != root && streq(name, "layout"))
306 agwarningf("layout attribute is invalid except on the root graph\n");
307 if (kind == AGRAPH) {
308 unviewsubgraphsattr(g,name);
309 }
310 agstrfree(g, lsym->defval, aghtmlstr(lsym->defval));
311 lsym->defval = is_html ? agstrdup_html(g, value) : agstrdup(g, value);
312 rv = lsym;
313 } else {
314 psym = agdictsym(ldict, name); /* search with viewpath up to root */
315 if (psym) { /* new local definition */
316 lsym = agnewsym(g, name, value, is_html, psym->id, kind);
317 dtinsert(ldict, lsym);
318 rv = lsym;
319 } else { /* new global definition */
320 rdict = agdictof(root, kind);
321 rsym = agnewsym(g, name, value, is_html, dtsize(rdict), kind);
322 dtinsert(rdict, rsym);
323 switch (kind) {
324 case AGRAPH:
325 agapply(root, (Agobj_t *)root, (agobjfn_t)addattr, rsym, true);
326 break;
327 case AGNODE:
328 for (n = agfstnode(root); n; n = agnxtnode(root, n))
329 addattr(g, (Agobj_t *) n, rsym);
330 break;
331 case AGINEDGE:
332 case AGOUTEDGE:
333 for (n = agfstnode(root); n; n = agnxtnode(root, n))
334 for (e = agfstout(root, n); e; e = agnxtout(root, e))
335 addattr(g, (Agobj_t *) e, rsym);
336 break;
337 default:
338 UNREACHABLE();
339 }
340 rv = rsym;
341 }
342 }
343 if (rv && kind == AGRAPH)
344 agxset_(g, rv, value, is_html);
345 agmethod_upd(g, g, rv);
346 return rv;
347}
348
349/*
350 * create or update an existing attribute and return its descriptor.
351 * if the new value is NULL, this is only a search, no update.
352 * when a new attribute is created, existing graphs/nodes/edges
353 * receive its default value.
354 */
355static Agsym_t *agattr_(Agraph_t *g, int kind, char *name, const char *value,
356 bool is_html) {
357 Agsym_t *rv;
358
359 if (g == 0) {
360 if (ProtoGraph == 0)
361 ProtoGraph = agopen(0, ProtoDesc, 0);
362 g = ProtoGraph;
363 }
364 if (value)
365 rv = setattr(g, kind, name, value, is_html);
366 else
367 rv = getattr(g, kind, name);
368 return rv;
369}
370
371Agsym_t *agattr(Agraph_t *g, int kind, char *name, const char *value) {
372 return agattr_(g, kind, name, value, false);
373}
374
375Agsym_t *agattr_html(Agraph_t *g, int kind, char *name, const char *value) {
376 return agattr_(g, kind, name, value, true);
377}
378
379Agsym_t *agnxtattr(Agraph_t * g, int kind, Agsym_t * attr)
380{
381 Dict_t *d;
382 Agsym_t *rv;
383
384 if ((d = agdictof(g, kind))) {
385 if (attr)
386 rv = dtnext(d, attr);
387 else
388 rv = dtfirst(d);
389 } else
390 rv = 0;
391 return rv;
392}
393
394/* Create or delete attributes associated with an object */
395
397{
398 Agraph_t *context;
399
400 g->desc.has_attrs = true;
402 if (!(context = agparent(g)))
403 context = g;
404 agmakeattrs(context, g);
405}
406
408{
409 Agdatadict_t *dd;
410 Agattr_t *attr;
411
412 Ag_G_global = g;
413 if ((attr = agattrrec(g))) {
414 freeattr((Agobj_t *) g, attr);
415 agdelrec(g, attr->h.name);
416 }
417
418 if ((dd = agdatadict(g, false))) {
419 if (agdtclose(g, dd->dict.n)) return 1;
420 if (agdtclose(g, dd->dict.e)) return 1;
421 if (agdtclose(g, dd->dict.g)) return 1;
422 agdelrec(g, dd->h.name);
423 }
424 return 0;
425}
426
428{
429 Agattr_t *data;
430
431 data = agattrrec(n);
432 if (!data || !data->dict)
433 (void) agmakeattrs(g, n);
434}
435
437{
438 Agattr_t *rec;
439
440 if ((rec = agattrrec(n))) {
441 freeattr((Agobj_t *) n, rec);
443 }
444}
445
447{
448 Agattr_t *data;
449
450 data = agattrrec(e);
451 if (!data || !data->dict)
452 (void) agmakeattrs(g, e);
453}
454
456{
457 Agattr_t *rec;
458
459 if ((rec = agattrrec(e))) {
460 freeattr((Agobj_t *) e, rec);
462 }
463}
464
465char *agget(void *obj, char *name)
466{
467 Agsym_t *sym;
468 Agattr_t *data;
469 char *rv;
470
471 sym = agattrsym(obj, name);
472 if (sym == NULL)
473 rv = 0; /* note was "", but this provides more info */
474 else {
475 data = agattrrec(obj);
476 rv = data->str[sym->id];
477 }
478 return rv;
479}
480
481char *agxget(void *obj, Agsym_t * sym)
482{
483 Agattr_t *data;
484 char *rv;
485
486 data = agattrrec(obj);
487 assert(sym->id >= 0 && sym->id < topdictsize(obj));
488 rv = data->str[sym->id];
489 return rv;
490}
491
492int agset(void *obj, char *name, const char *value) {
493 Agsym_t *sym;
494 int rv;
495
496 sym = agattrsym(obj, name);
497 if (sym == NULL)
498 rv = FAILURE;
499 else
500 rv = agxset(obj, sym, value);
501 return rv;
502}
503
504static int agxset_(void *obj, Agsym_t *sym, const char *value, bool is_html) {
505 Agraph_t *g;
506 Agobj_t *hdr;
507 Agattr_t *data;
508 Agsym_t *lsym;
509
510 g = agraphof(obj);
511 hdr = obj;
512 data = agattrrec(hdr);
513 assert(sym->id >= 0 && sym->id < topdictsize(obj));
514 agstrfree(g, data->str[sym->id], aghtmlstr(data->str[sym->id]));
515 data->str[sym->id] = is_html ? agstrdup_html(g, value) : agstrdup(g, value);
516 if (hdr->tag.objtype == AGRAPH) {
517 /* also update dict default */
518 Dict_t *dict;
519 dict = agdatadict(g, false)->dict.g;
520 if ((lsym = aglocaldictsym(dict, sym->name))) {
521 agstrfree(g, lsym->defval, aghtmlstr(lsym->defval));
522 lsym->defval = is_html ? agstrdup_html(g, value) : agstrdup(g, value);
523 } else {
524 lsym = agnewsym(g, sym->name, value, is_html, sym->id, AGTYPE(hdr));
525 dtinsert(dict, lsym);
526 }
527 }
528 agmethod_upd(g, obj, sym);
529 return SUCCESS;
530}
531
532int agxset(void *obj, Agsym_t *sym, const char *value) {
533 return agxset_(obj, sym, value, false);
534}
535
536int agxset_html(void *obj, Agsym_t *sym, const char *value) {
537 return agxset_(obj, sym, value, true);
538}
539
540int agsafeset(void *obj, char *name, const char *value, const char *def) {
541 Agsym_t *a;
542
543 a = agattr(agraphof(obj), AGTYPE(obj), name, 0);
544 if (!a)
545 a = agattr(agraphof(obj), AGTYPE(obj), name, def);
546 return agxset(obj, a, value);
547}
548
549static void agraphattr_init_wrapper(Agraph_t *g, Agobj_t *ignored1,
550 void *ignored2) {
551 (void)ignored1;
552 (void)ignored2;
553
555}
556
557/*
558 * attach attributes to the already created graph objs.
559 * presumably they were already initialized, so we don't invoke
560 * any of the old methods.
561 */
562static void init_all_attrs(Agraph_t * g)
563{
564 Agraph_t *root;
565 Agnode_t *n;
566 Agedge_t *e;
567
568 root = agroot(g);
569 agapply(root, (Agobj_t*)root, agraphattr_init_wrapper, NULL, true);
570 for (n = agfstnode(root); n; n = agnxtnode(root, n)) {
571 agnodeattr_init(g, n);
572 for (e = agfstout(root, n); e; e = agnxtout(root, e)) {
573 agedgeattr_init(g, e);
574 }
575 }
576}
577
578/* Assumes attributes have already been declared.
579 * Do not copy key attribute for edges, as this must be distinct.
580 * Returns non-zero on failure or if objects have different type.
581 */
582int agcopyattr(void *oldobj, void *newobj)
583{
584 Agraph_t *g;
585 Agsym_t *sym;
586 Agsym_t *newsym;
587 char* val;
588 int r = 1;
589
590 g = agraphof(oldobj);
591 if (AGTYPE(oldobj) != AGTYPE(newobj))
592 return 1;
593 sym = 0;
594 while ((sym = agnxtattr(g, AGTYPE(oldobj), sym))) {
595 newsym = agattrsym(newobj, sym->name);
596 if (!newsym)
597 return 1;
598 val = agxget(oldobj, sym);
599 if (aghtmlstr(val)) {
600 r = agxset_html(newobj, newsym, val);
601 } else {
602 r = agxset(newobj, newsym, val);
603 }
604 }
605 return r;
606}
Memory allocation wrappers that exit on failure.
static void * gv_recalloc(void *ptr, size_t old_nmemb, size_t new_nmemb, size_t size)
Definition alloc.h:73
static void * gv_calloc(size_t nmemb, size_t size)
Definition alloc.h:26
static void * gv_alloc(size_t size)
Definition alloc.h:47
int agapply(Agraph_t *g, Agobj_t *obj, agobjfn_t fn, void *arg, int preorder)
Definition apply.c:60
static void agraphattr_init_wrapper(Agraph_t *g, Agobj_t *ignored1, void *ignored2)
Definition attr.c:549
static Agsym_t * agdictsym(Dict_t *dict, char *name)
Definition attr.c:139
static int agxset_(void *obj, Agsym_t *sym, const char *value, bool is_html)
Definition attr.c:504
#define MINATTR
Definition attr.c:30
static void freeattr(Agobj_t *obj, Agattr_t *attr)
Definition attr.c:215
char * AgDataRecName
Definition attr.c:173
static Agdatadict_t * agmakedatadict(Agraph_t *g)
Definition attr.c:110
static Agraph_t * ProtoGraph
Definition attr.c:47
static Agsym_t * setattr(Agraph_t *g, int kind, char *name, const char *value, bool is_html)
Definition attr.c:291
static int topdictsize(Agobj_t *obj)
Definition attr.c:175
static Agdesc_t ProtoDesc
Definition attr.c:45
static Dict_t * agdictof(Agraph_t *g, int kind)
Definition attr.c:58
static void init_all_attrs(Agraph_t *g)
Definition attr.c:562
static Agsym_t * agnewsym(Agraph_t *g, const char *name, const char *value, bool is_html, int id, int kind)
Definition attr.c:86
Dtdisc_t AgDataDictDisc
Definition attr.c:34
static void addattr(Agraph_t *g, Agobj_t *obj, Agsym_t *sym)
Definition attr.c:242
static Agrec_t * agmakeattrs(Agraph_t *context, void *obj)
Definition attr.c:184
static void unviewsubgraphsattr(Agraph_t *parent, char *name)
Definition attr.c:266
static Agsym_t * aglocaldictsym(Dict_t *dict, char *name)
Definition attr.c:147
static void agcopydict(Dict_t *src, Dict_t *dest, Agraph_t *g, int kind)
Definition attr.c:96
static void freesym(void *obj)
Definition attr.c:227
static Agsym_t * agattr_(Agraph_t *g, int kind, char *name, const char *value, bool is_html)
Definition attr.c:355
static char DataDictName[]
Definition attr.c:43
static Agsym_t * getattr(Agraph_t *g, int kind, char *name)
Definition attr.c:256
#define dtsearch(d, o)
Definition cdt.h:183
CDT_API int dtsize(Dt_t *)
Definition dtsize.c:12
#define dtinsert(d, o)
Definition cdt.h:185
CDT_API Dt_t * dtview(Dt_t *, Dt_t *)
Definition dtview.c:91
CDT_API Dtmethod_t * Dttree
Definition dttree.c:308
#define dtnext(d, o)
Definition cdt.h:180
#define dtfirst(d)
Definition cdt.h:179
cgraph.h additions
Dict_t * agdtopen(Dtdisc_t *disc, Dtmethod_t *method)
Definition utils.c:21
Agraph_t * Ag_G_global
Definition graph.c:24
#define FAILURE
Definition cghdr.h:45
#define SUCCESS
Definition cghdr.h:44
int agdtclose(Agraph_t *g, Dict_t *dict)
Definition utils.c:31
#define parent(i)
Definition closest.c:80
void free(void *)
node NULL
Definition grammar.y:163
Agattr_t * agattrrec(void *obj)
Definition attr.c:236
void agnodeattr_init(Agraph_t *g, Agnode_t *n)
Definition attr.c:427
void agnodeattr_delete(Agnode_t *n)
Definition attr.c:436
Agsym_t * agattrsym(void *obj, char *name)
looks up a string attribute for a graph object given as an argument
Definition attr.c:158
Agsym_t * agattr(Agraph_t *g, int kind, char *name, const char *value)
creates or looks up attributes of a graph
Definition attr.c:371
int agset(void *obj, char *name, const char *value)
Definition attr.c:492
Agsym_t * agnxtattr(Agraph_t *g, int kind, Agsym_t *attr)
permits traversing the list of attributes of a given type
Definition attr.c:379
void agedgeattr_init(Agraph_t *g, Agedge_t *e)
Definition attr.c:446
int agxset(void *obj, Agsym_t *sym, const char *value)
Definition attr.c:532
void agraphattr_init(Agraph_t *g)
Definition attr.c:396
int agxset_html(void *obj, Agsym_t *sym, const char *value)
Definition attr.c:536
char * agget(void *obj, char *name)
Definition attr.c:465
int agsafeset(void *obj, char *name, const char *value, const char *def)
ensures the given attribute is declared before setting it locally on an object
Definition attr.c:540
void agedgeattr_delete(Agedge_t *e)
Definition attr.c:455
Agdatadict_t * agdatadict(Agraph_t *g, bool cflag)
Definition attr.c:49
char * agxget(void *obj, Agsym_t *sym)
Definition attr.c:481
int agcopyattr(void *oldobj, void *newobj)
copies all of the attributes from one object to another
Definition attr.c:582
int agraphattr_delete(Agraph_t *g)
Definition attr.c:407
Agsym_t * agattr_html(Agraph_t *g, int kind, char *name, const char *value)
agattr, but creates HTML-like values
Definition attr.c:375
void agmethod_upd(Agraph_t *g, void *obj, Agsym_t *sym)
Definition obj.c:108
Agedge_t * agfstout(Agraph_t *g, Agnode_t *n)
Definition edge.c:24
Agedge_t * agnxtout(Agraph_t *g, Agedge_t *e)
Definition edge.c:39
void agwarningf(const char *fmt,...)
Definition agerror.c:173
void agerrorf(const char *fmt,...)
Definition agerror.c:165
void(* agobjfn_t)(Agraph_t *g, Agobj_t *obj, void *arg)
Definition cgraph.h:368
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
Agnode_t * agnxtnode(Agraph_t *g, Agnode_t *n)
Definition node.c:47
Agnode_t * agfstnode(Agraph_t *g)
Definition node.c:40
Agraph_t * agraphof(void *obj)
Definition obj.c:185
#define AGTYPE(obj)
returns AGRAPH, AGNODE, or AGEDGE depending on the type of the object
Definition cgraph.h:216
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 * 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
int agdelrec(void *obj, const char *name)
deletes a named record from one object
Definition rec.c:137
int aghtmlstr(const char *)
Definition refstr.c:401
int agstrfree(Agraph_t *, const char *, bool is_html)
Definition refstr.c:378
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:370
char * agstrdup_html(Agraph_t *, const char *)
Definition refstr.c:374
Agraph_t * agparent(Agraph_t *g)
Definition subg.c:88
Agraph_t * agfstsubg(Agraph_t *g)
Definition subg.c:75
Agraph_t * agnxtsubg(Agraph_t *subg)
Definition subg.c:80
static uint64_t id
Definition gv2gml.c:42
ViewInfo * view
Definition viewport.c:37
static bool streq(const char *a, const char *b)
are a and b equal?
Definition streq.h:11
string attribute container
Definition cgraph.h:633
char ** str
the attribute string values indexed by Agsym_s.id
Definition cgraph.h:636
Dict_t * dict
shared dict of Agsym_s to interpret Agattr_s.str
Definition cgraph.h:635
Agrec_t h
Definition cgraph.h:634
Dict_t * n
Definition cgraph.h:654
Dict_t * e
Definition cgraph.h:654
struct Agdatadict_s::@64 dict
Dict_t * g
Definition cgraph.h:654
Agrec_t h
< set of dictionaries per graph
Definition cgraph.h:652
graph descriptor
Definition cgraph.h:284
unsigned has_attrs
Definition cgraph.h:290
unsigned directed
Definition cgraph.h:285
a generic header of Agraph_s, Agnode_s and Agedge_s
Definition cgraph.h:210
Agtag_t tag
access with AGTAG
Definition cgraph.h:211
graph or subgraph
Definition cgraph.h:424
Agdesc_t desc
Definition cgraph.h:426
implementation of Agrec_t
Definition cgraph.h:172
char * name
Definition cgraph.h:173
string attribute descriptor symbol in Agattr_s.dict
Definition cgraph.h:641
char * name
Definition cgraph.h:643
unsigned char kind
Definition cgraph.h:646
int id
index in Agattr_s.str
Definition cgraph.h:645
unsigned char fixed
Definition cgraph.h:647
char * defval
Definition cgraph.h:644
unsigned char print
Definition cgraph.h:648
unsigned objtype
access with AGTYPE
Definition cgraph.h:199
Definition legal.c:50
Definition cdt.h:100
#define UNREACHABLE()
Definition unreachable.h:30