Graphviz 13.0.0~dev.20250329.0043
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 Agsym_t *rv;
294
295 assert(value);
296 Agraph_t *root = agroot(g);
297 agdatadict(g, true); /* force initialization of string attributes */
298 Dict_t *ldict = agdictof(g, kind);
299 Agsym_t *lsym = aglocaldictsym(ldict, name);
300 if (lsym) { /* update old local definition */
301 if (g != root && streq(name, "layout"))
302 agwarningf("layout attribute is invalid except on the root graph\n");
303 if (kind == AGRAPH) {
304 unviewsubgraphsattr(g,name);
305 }
306 agstrfree(g, lsym->defval, aghtmlstr(lsym->defval));
307 lsym->defval = is_html ? agstrdup_html(g, value) : agstrdup(g, value);
308 rv = lsym;
309 } else {
310 Agsym_t *psym = agdictsym(ldict, name); // search with viewpath up to root
311 if (psym) { /* new local definition */
312 lsym = agnewsym(g, name, value, is_html, psym->id, kind);
313 dtinsert(ldict, lsym);
314 rv = lsym;
315 } else { /* new global definition */
316 Dict_t *rdict = agdictof(root, kind);
317 Agsym_t *rsym = agnewsym(g, name, value, is_html, dtsize(rdict), kind);
318 dtinsert(rdict, rsym);
319 switch (kind) {
320 case AGRAPH:
321 agapply(root, &root->base, (agobjfn_t)addattr, rsym, true);
322 break;
323 case AGNODE:
324 for (Agnode_t *n = agfstnode(root); n; n = agnxtnode(root, n))
325 addattr(g, &n->base, rsym);
326 break;
327 case AGINEDGE:
328 case AGOUTEDGE:
329 for (Agnode_t *n = agfstnode(root); n; n = agnxtnode(root, n))
330 for (Agedge_t *e = agfstout(root, n); e; e = agnxtout(root, e))
331 addattr(g, &e->base, rsym);
332 break;
333 default:
334 UNREACHABLE();
335 }
336 rv = rsym;
337 }
338 }
339 if (rv && kind == AGRAPH)
340 agxset_(g, rv, value, is_html);
341 agmethod_upd(g, g, rv);
342 return rv;
343}
344
345/*
346 * create or update an existing attribute and return its descriptor.
347 * if the new value is NULL, this is only a search, no update.
348 * when a new attribute is created, existing graphs/nodes/edges
349 * receive its default value.
350 */
351static Agsym_t *agattr_(Agraph_t *g, int kind, char *name, const char *value,
352 bool is_html) {
353 Agsym_t *rv;
354
355 if (g == 0) {
356 if (ProtoGraph == 0)
357 ProtoGraph = agopen(0, ProtoDesc, 0);
358 g = ProtoGraph;
359 }
360 if (value)
361 rv = setattr(g, kind, name, value, is_html);
362 else
363 rv = getattr(g, kind, name);
364 return rv;
365}
366
367Agsym_t *agattr(Agraph_t *g, int kind, char *name, const char *value) {
368 return agattr_(g, kind, name, value, false);
369}
370
371Agsym_t *agattr_html(Agraph_t *g, int kind, char *name, const char *value) {
372 return agattr_(g, kind, name, value, true);
373}
374
375Agsym_t *agnxtattr(Agraph_t * g, int kind, Agsym_t * attr)
376{
377 Dict_t *d;
378 Agsym_t *rv;
379
380 if ((d = agdictof(g, kind))) {
381 if (attr)
382 rv = dtnext(d, attr);
383 else
384 rv = dtfirst(d);
385 } else
386 rv = 0;
387 return rv;
388}
389
390/* Create or delete attributes associated with an object */
391
393{
394 Agraph_t *context;
395
396 g->desc.has_attrs = true;
398 if (!(context = agparent(g)))
399 context = g;
400 agmakeattrs(context, g);
401}
402
404{
405 Agdatadict_t *dd;
406 Agattr_t *attr;
407
408 Ag_G_global = g;
409 if ((attr = agattrrec(g))) {
410 freeattr(&g->base, attr);
411 agdelrec(g, attr->h.name);
412 }
413
414 if ((dd = agdatadict(g, false))) {
415 if (agdtclose(g, dd->dict.n)) return 1;
416 if (agdtclose(g, dd->dict.e)) return 1;
417 if (agdtclose(g, dd->dict.g)) return 1;
418 agdelrec(g, dd->h.name);
419 }
420 return 0;
421}
422
424{
425 Agattr_t *data;
426
427 data = agattrrec(n);
428 if (!data || !data->dict)
429 (void) agmakeattrs(g, n);
430}
431
433{
434 Agattr_t *rec;
435
436 if ((rec = agattrrec(n))) {
437 freeattr(&n->base, rec);
439 }
440}
441
443{
444 Agattr_t *data;
445
446 data = agattrrec(e);
447 if (!data || !data->dict)
448 (void) agmakeattrs(g, e);
449}
450
452{
453 Agattr_t *rec;
454
455 if ((rec = agattrrec(e))) {
456 freeattr(&e->base, rec);
458 }
459}
460
461char *agget(void *obj, char *name)
462{
463 Agsym_t *const sym = agattrsym(obj, name);
464 if (sym == NULL) {
465 return NULL; // note was "", but this provides more info
466 }
467 Agattr_t *const data = agattrrec(obj);
468 return data->str[sym->id];
469}
470
471char *agxget(void *obj, Agsym_t * sym)
472{
473 Agattr_t *const data = agattrrec(obj);
474 assert(sym->id >= 0 && sym->id < topdictsize(obj));
475 return data->str[sym->id];
476}
477
478int agset(void *obj, char *name, const char *value) {
479 Agsym_t *sym;
480 int rv;
481
482 sym = agattrsym(obj, name);
483 if (sym == NULL)
484 rv = FAILURE;
485 else
486 rv = agxset(obj, sym, value);
487 return rv;
488}
489
490static int agxset_(void *obj, Agsym_t *sym, const char *value, bool is_html) {
491 Agraph_t *g;
492 Agobj_t *hdr;
493 Agattr_t *data;
494 Agsym_t *lsym;
495
496 g = agraphof(obj);
497 hdr = obj;
498 data = agattrrec(hdr);
499 assert(sym->id >= 0 && sym->id < topdictsize(obj));
500 agstrfree(g, data->str[sym->id], aghtmlstr(data->str[sym->id]));
501 data->str[sym->id] = is_html ? agstrdup_html(g, value) : agstrdup(g, value);
502 if (hdr->tag.objtype == AGRAPH) {
503 /* also update dict default */
504 Dict_t *dict;
505 dict = agdatadict(g, false)->dict.g;
506 if ((lsym = aglocaldictsym(dict, sym->name))) {
507 agstrfree(g, lsym->defval, aghtmlstr(lsym->defval));
508 lsym->defval = is_html ? agstrdup_html(g, value) : agstrdup(g, value);
509 } else {
510 lsym = agnewsym(g, sym->name, value, is_html, sym->id, AGTYPE(hdr));
511 dtinsert(dict, lsym);
512 }
513 }
514 agmethod_upd(g, obj, sym);
515 return SUCCESS;
516}
517
518int agxset(void *obj, Agsym_t *sym, const char *value) {
519 return agxset_(obj, sym, value, false);
520}
521
522int agxset_html(void *obj, Agsym_t *sym, const char *value) {
523 return agxset_(obj, sym, value, true);
524}
525
526int agsafeset(void *obj, char *name, const char *value, const char *def) {
527 Agsym_t *a;
528
529 a = agattr(agraphof(obj), AGTYPE(obj), name, 0);
530 if (!a)
531 a = agattr(agraphof(obj), AGTYPE(obj), name, def);
532 return agxset(obj, a, value);
533}
534
535static void agraphattr_init_wrapper(Agraph_t *g, Agobj_t *ignored1,
536 void *ignored2) {
537 (void)ignored1;
538 (void)ignored2;
539
541}
542
543/*
544 * attach attributes to the already created graph objs.
545 * presumably they were already initialized, so we don't invoke
546 * any of the old methods.
547 */
548static void init_all_attrs(Agraph_t * g)
549{
550 Agraph_t *root;
551 Agnode_t *n;
552 Agedge_t *e;
553
554 root = agroot(g);
555 agapply(root, &root->base, agraphattr_init_wrapper, NULL, true);
556 for (n = agfstnode(root); n; n = agnxtnode(root, n)) {
557 agnodeattr_init(g, n);
558 for (e = agfstout(root, n); e; e = agnxtout(root, e)) {
559 agedgeattr_init(g, e);
560 }
561 }
562}
563
564/* Assumes attributes have already been declared.
565 * Do not copy key attribute for edges, as this must be distinct.
566 * Returns non-zero on failure or if objects have different type.
567 */
568int agcopyattr(void *oldobj, void *newobj)
569{
570 Agraph_t *g;
571 Agsym_t *sym;
572 Agsym_t *newsym;
573 char* val;
574 int r = 1;
575
576 g = agraphof(oldobj);
577 if (AGTYPE(oldobj) != AGTYPE(newobj))
578 return 1;
579 sym = 0;
580 while ((sym = agnxtattr(g, AGTYPE(oldobj), sym))) {
581 newsym = agattrsym(newobj, sym->name);
582 if (!newsym)
583 return 1;
584 val = agxget(oldobj, sym);
585 if (aghtmlstr(val)) {
586 r = agxset_html(newobj, newsym, val);
587 } else {
588 r = agxset(newobj, newsym, val);
589 }
590 }
591 return r;
592}
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:535
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:490
#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:548
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:351
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:423
void agnodeattr_delete(Agnode_t *n)
Definition attr.c:432
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:367
int agset(void *obj, char *name, const char *value)
Definition attr.c:478
Agsym_t * agnxtattr(Agraph_t *g, int kind, Agsym_t *attr)
permits traversing the list of attributes of a given type
Definition attr.c:375
void agedgeattr_init(Agraph_t *g, Agedge_t *e)
Definition attr.c:442
int agxset(void *obj, Agsym_t *sym, const char *value)
Definition attr.c:518
void agraphattr_init(Agraph_t *g)
Definition attr.c:392
int agxset_html(void *obj, Agsym_t *sym, const char *value)
Definition attr.c:522
char * agget(void *obj, char *name)
Definition attr.c:461
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:526
void agedgeattr_delete(Agedge_t *e)
Definition attr.c:451
Agdatadict_t * agdatadict(Agraph_t *g, bool cflag)
Definition attr.c:49
char * agxget(void *obj, Agsym_t *sym)
Definition attr.c:471
int agcopyattr(void *oldobj, void *newobj)
copies all of the attributes from one object to another
Definition attr.c:568
int agraphattr_delete(Agraph_t *g)
Definition attr.c:403
Agsym_t * agattr_html(Agraph_t *g, int kind, char *name, const char *value)
agattr, but creates HTML-like values
Definition attr.c:371
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:41
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:628
char ** str
the attribute string values indexed by Agsym_s.id
Definition cgraph.h:631
Dict_t * dict
shared dict of Agsym_s to interpret Agattr_s.str
Definition cgraph.h:630
Agrec_t h
Definition cgraph.h:629
Dict_t * n
Definition cgraph.h:649
Dict_t * e
Definition cgraph.h:649
Dict_t * g
Definition cgraph.h:649
struct Agdatadict_s::@65 dict
Agrec_t h
< set of dictionaries per graph
Definition cgraph.h:647
graph descriptor
Definition cgraph.h:284
unsigned has_attrs
Definition cgraph.h:290
unsigned directed
Definition cgraph.h:285
Agobj_t base
Definition cgraph.h:269
Agobj_t base
Definition cgraph.h:260
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
Agobj_t base
Definition cgraph.h:425
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:636
char * name
Definition cgraph.h:638
unsigned char kind
Definition cgraph.h:641
int id
index in Agattr_s.str
Definition cgraph.h:640
unsigned char fixed
Definition cgraph.h:642
char * defval
Definition cgraph.h:639
unsigned char print
Definition cgraph.h:643
unsigned objtype
access with AGTYPE
Definition cgraph.h:199
Definition legal.c:50
Definition cdt.h:100
#define UNREACHABLE()
Definition unreachable.h:30