Graphviz 13.0.0~dev.20250424.1043
Loading...
Searching...
No Matches

symbols, and records More...

Collaboration diagram for attributes:

Modules

 records
 These records are attached by client programs dynamically at runtime.
 

Files

file  attr.c
 implementation of dynamic attributes
 

Data Structures

struct  Agattr_s
 string attribute container More...
 
struct  Agsym_s
 string attribute descriptor symbol in Agattr_s.dict More...
 
struct  Agdatadict_s
 

Functions

Agdatadict_tagdatadict (Agraph_t *g, bool cflag)
 
Agattr_tagattrrec (void *obj)
 
void agraphattr_init (Agraph_t *g)
 
int agraphattr_delete (Agraph_t *g)
 
void agnodeattr_init (Agraph_t *g, Agnode_t *n)
 
void agnodeattr_delete (Agnode_t *n)
 
void agedgeattr_init (Agraph_t *g, Agedge_t *e)
 
void agedgeattr_delete (Agedge_t *e)
 
Agsym_tagattr_text (Agraph_t *g, int kind, char *name, const char *value)
 creates or looks up text attributes of a graph
 
Agsym_tagattr_html (Agraph_t *g, int kind, char *name, const char *value)
 agattr_text, but creates HTML-like values
 
Agsym_tagattr (Agraph_t *g, int kind, char *name, const char *value)
 creates or looks up an attribute, without specifying desired form
 
Agsym_tagattrsym (void *obj, char *name)
 looks up a string attribute for a graph object given as an argument
 
Agsym_tagnxtattr (Agraph_t *g, int kind, Agsym_t *attr)
 permits traversing the list of attributes of a given type
 
int agcopyattr (void *oldobj, void *newobj)
 copies all of the attributes from one object to another
 
char * agget (void *obj, char *name)
 
char * agxget (void *obj, Agsym_t *sym)
 
int agset (void *obj, char *name, const char *value)
 
int agset_text (void *obj, char *name, const char *value)
 
int agset_html (void *obj, char *name, const char *value)
 
int agxset (void *obj, Agsym_t *sym, const char *value)
 
int agxset_text (void *obj, Agsym_t *sym, const char *value)
 
int agxset_html (void *obj, Agsym_t *sym, const char *value)
 
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
 
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
 
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
 

Detailed Description

Programmer-defined values may be dynamically attached to graphs, subgraphs, nodes, and edges. Such values are either character string data (see agattr_text, agattr_html, and agattr) (for I/O) or uninterpreted binary records (for implementing algorithms efficiently).

String attributes are handled automatically in reading and writing graph files. A string attribute is identified by name and by an internal symbol table entry (Agsym_t) created by Libcgraph. Attributes of nodes, edges, and graphs (with their subgraphs) have separate namespaces. The contents of an Agsym_t have a char* name for the attribute's name, a char* defval field for the attribute's default value, and an int id field containing the index of the attribute's specific value for an object in the object's array of attribute values.

Function Documentation

◆ agattr()

Agsym_t * agattr ( Agraph_t g,
int  kind,
char *  name,
const char *  value 
)

Use of this function should be avoided where possible. It is not possible to explicitly indicate whether the caller is trying to create/lookup a regular text attribute or an HTML-like attribute. It is better to be explicit with your intent and instead call either agattr_text or agattr_html.

This function has the following behavior:

  1. If the value passed was obtained from agstrdup_html, an HTML-like attribute value is created/looked up. That is, the behavior is equivalent to a call to agattr_html.
  2. Otherwise, a regular text attribute value is created/looked up.
Parameters
ggraph. When is NULL, the default is set for all graphs created subsequently.
kindmay be AGRAPH, AGNODE, or AGEDGE.
valuedefault value. When is NULL, the request is to search for for an existing attribute of the given kind and name.

Definition at line 365 of file attr.c.

References agattr_html(), agattr_text(), aghtmlstr(), agopen(), agstrbind_html(), NULL, ProtoDesc, and ProtoGraph.

Here is the call graph for this function:

◆ agattr_html()

Agsym_t * agattr_html ( Agraph_t g,
int  kind,
char *  name,
const char *  value 
)

Regular text attributes cannot be created or looked up with this function. See agattr_text for that.

Parameters
gGraph. When g is NULL, the default is set for all graphs created subsequently.
kindMay be AGRAPH, AGNODE, or AGEDGE.
valueDefault value. When value is NULL, the request is to search for an existing attribute of the given kind and name.

If the attribute already exists, its default for creating new objects is set to the given value; if it does not exist, a new attribute is created with the given default value, and the default is applied to all pre-existing objects of the given kind.

Definition at line 361 of file attr.c.

References agattr_().

Referenced by agattr(), agsafeset(), agsafeset_html(), attrstmt(), attrstmt(), cloneDfltAttrs(), cloneGraph(), and copyAttr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agattr_text()

Agsym_t * agattr_text ( Agraph_t g,
int  kind,
char *  name,
const char *  value 
)

HTML-like attributes cannot be created or looked up with this function. See agattr_html for that.

Parameters
ggraph. When is NULL, the default is set for all graphs created subsequently.
kindmay be AGRAPH, AGNODE, or AGEDGE.
valuedefault value. When is (char*)0, the request is to search for an existing attribute of the given kind and name.

If the attribute already exists, its default for creating new objects is set to the given value; if it does not exist, a new attribute is created with the given default value, and the default is applied to all pre-existing objects of the given kind

Definition at line 357 of file attr.c.

References agattr_().

Referenced by addRevEdge(), agattr(), agedgeattr(), agnodeattr(), agraphattr(), agsafeset(), agsafeset_text(), attach_edge_colors(), attached_clustering(), attrstmt(), attrstmt(), bindattrs(), bindattrs(), bindedgeattr(), cloneDfltAttrs(), cloneGraph(), cloneGraph(), clust_in_layer(), color(), constrainY(), copy_attr(), copyAttr(), copyAttr(), deselect_all(), doApply(), dot_sameports(), Dot_SetClusterColor(), dotneato_args_initialize(), emit_graph(), export_dot(), fdp_init_graph(), fdp_init_node_edge(), fdp_initParams(), get_checkbox_widget_to_attribute(), get_color_button_widget_to_attribute(), get_combobox_widget_to_attribute(), get_scalebtn_widget_to_attribute(), get_spinbtn_widget_to_attribute(), get_text_widget_to_attribute(), getAttrBool(), getAttrFloat(), getAttrInt(), getAttrStr(), getDfltAttr(), getv(), getv(), getval(), global_def(), graph_init(), graphRecord(), gvContext(), gvContextPlugins(), gvplugin_graph(), Import_coord_clusters_from_dot(), Import_dot_splines(), init_info(), init_nop(), initGraphAttrs(), initialPositions(), layout(), loadGraph(), lookup(), makeDotGraph(), makeGraphData(), mkport(), mkport(), neatoModel(), nxtAttr(), on_attrAddBtn_clicked(), patchwork_init_graph(), plot_dot_map(), posOf(), post(), pre(), safe_dcl(), scan_graph_mode(), select_edge(), select_node(), set_visibility(), setattr(), setAttr(), setDfltAttr(), setedgeattributes(), setgraphattributes(), setnodeattributes(), setState(), setv(), setv(), SparseMatrix_import_dot(), twopi_layout(), update_graph_params(), updateRecord(), write_hdr(), and writeHdr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agattrrec()

Agattr_t * agattrrec ( void *  obj)

Definition at line 227 of file attr.c.

References AgDataRecName, and aggetrec().

Referenced by addattr(), agattrsym(), agedgeattr_delete(), agedgeattr_init(), agget(), agnodeattr_delete(), agnodeattr_init(), agraphattr_delete(), agxget(), agxset_(), irrelevant_subgraph(), not_default_attrs(), write_nondefault_attrs(), and writeNondefaultAttr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agattrsym()

Agsym_t * agattrsym ( void *  obj,
char *  name 
)

Definition at line 154 of file attr.c.

References agattrrec(), agdictsym(), and NULL.

Referenced by agcopyattr(), agget(), agset_(), copyAttr(), getval(), lookup(), post(), and setattr().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agcopyattr()

int agcopyattr ( void *  oldobj,
void *  newobj 
)
Returns
fails and returns non-zero if argument objects are different kinds, or if all of the attributes of the source object have not been declared for the target object

Definition at line 659 of file attr.c.

References agattrsym(), aghtmlstr(), agnxtattr(), agraphof(), AGTYPE, agxget(), agxset(), agxset_html(), and Agsym_s::name.

Referenced by addRevEdge(), cloneEdge(), cloneEdge(), cloneNode(), and projectG().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agdatadict()

Agdatadict_t * agdatadict ( Agraph_t g,
bool  cflag 
)

Definition at line 49 of file attr.c.

References aggetrec(), DataDictName, and init_all_attrs().

Referenced by agdictof(), agmakedatadict(), agraphattr_delete(), agxset_(), irrelevant_subgraph(), setattr(), unviewsubgraphsattr(), write_body(), write_dicts(), writeBody(), and writeDicts().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agedgeattr_delete()

void agedgeattr_delete ( Agedge_t e)

Definition at line 462 of file attr.c.

References agattrrec(), AgDataRecName, agdelrec(), Agedge_s::base, and freeattr().

Referenced by agdeledge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agedgeattr_init()

void agedgeattr_init ( Agraph_t g,
Agedge_t e 
)

Definition at line 453 of file attr.c.

References agattrrec(), and agmakeattrs().

Referenced by init_all_attrs(), and newedge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agget()

char * agget ( void *  obj,
char *  name 
)

Definition at line 472 of file attr.c.

References agattrrec(), agattrsym(), Agsym_s::id, and NULL.

Referenced by adjustNodes(), agwrite(), angleSet(), attach_attrs_and_arrows(), bind_shape(), changetopfishfocus(), checkClusterStyle(), chkBoundBox(), chkOrder(), circularLayout(), color(), common_init_edge(), compile_samerank(), copy_attr(), do_graph_label(), dot2_rank(), dot_mincross(), dot_rank(), dotLayout(), edgeAttrs(), emit_background(), emit_begin_edge(), emit_begin_node(), emit_cluster_colors(), emit_clusters(), emit_colors(), emit_edge_graphics(), emit_html_label(), emit_page(), epsf_init(), esepFactor(), fdp_xLayout(), gdgen_begin_page(), genRound(), get_attribute_value(), getdouble(), getdoubles2ptf(), getEdgeHead(), getEdgeTail(), getObjId(), getPack(), getPackModeInfo(), getPenColor(), graph_init(), graphAdjustMode(), graphAttrs(), gvLayoutJobs(), Import_coord_clusters_from_dot(), init_gvc(), init_job_viewport(), init_layering(), init_nop(), init_xdot(), initGraphAttrs(), initObjMapData(), is_a_cluster(), is_a_strong_cluster(), iterateBody(), iterateHdr(), labelOf(), load_settings_from_graph(), majorization(), makeCompoundEdge(), makeGraphData(), mincross_options(), neato_layout(), neatoLayout(), neatoMode(), neatoModel(), nsiter2(), object_color(), orthoEdges(), parse_layers(), parseXdotwithattrs(), poly_gencode(), poly_init(), populate_data(), prepare_topological_fisheye(), printHref(), putGraphs(), rank(), rank1(), rank_set_class(), rankset_kind(), scan_graph_mode(), sepFactor(), set_checkbox_widget(), set_color_button_widget(), set_combobox_widget(), set_label(), set_scalebtn_widget_to_attribute(), set_spinbtn_widget(), set_text_widget(), setAspect(), setEdgeType(), setRatio(), setSeed(), setup_tree(), simpleScale(), size_reclbl(), svg_begin_job(), svg_print_id_class(), TB_balance(), tuneControl(), twopi_layout(), update_graph_from_settings(), write_plain(), writeEdge(), writePort(), and xdot_begin_graph().

Here is the call graph for this function:

◆ agnodeattr_delete()

void agnodeattr_delete ( Agnode_t n)

Definition at line 443 of file attr.c.

References agattrrec(), AgDataRecName, agdelrec(), Agnode_s::base, and freeattr().

Referenced by agdelnode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agnodeattr_init()

void agnodeattr_init ( Agraph_t g,
Agnode_t n 
)

Definition at line 434 of file attr.c.

References agattrrec(), and agmakeattrs().

Referenced by init_all_attrs(), and initnode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agnxtattr()

Agsym_t * agnxtattr ( Agraph_t g,
int  kind,
Agsym_t attr 
)
Parameters
attrif NULL the function returns the first attribute
Returns
the next one in succession or NULL at the end of the list.

Definition at line 386 of file attr.c.

References agdictof(), dtfirst, and dtnext.

Referenced by agcopyattr(), cloneAttrs(), cloneDfltAttrs(), cloneGraph(), copyAttr(), emitEdgeAttrs(), emitGraphAttrs(), emitNodeAttrs(), fillDict(), firstattr(), firstattr(), firstattr(), listEdgeAttrs(), listGraphAttrs(), listNodeAttrs(), load_attr_list(), load_settings_from_graph(), mapN(), nextattr(), nextattr(), nextattr(), nxtAttr(), update_graph_from_settings(), and write_attrs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agraphattr_delete()

int agraphattr_delete ( Agraph_t g)

Definition at line 414 of file attr.c.

References Ag_G_global, agattrrec(), agdatadict(), agdelrec(), agdtclose(), Agraph_s::base, Agdatadict_s::dict, Agdatadict_s::e, freeattr(), Agdatadict_s::g, Agattr_s::h, Agdatadict_s::h, Agdatadict_s::n, and Agrec_s::name.

Referenced by agclose().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agraphattr_init()

void agraphattr_init ( Agraph_t g)

Definition at line 403 of file attr.c.

References agmakeattrs(), agmakedatadict(), agparent(), Agraph_s::desc, and Agdesc_s::has_attrs.

Referenced by agopen1(), and agraphattr_init_wrapper().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agsafeset()

int agsafeset ( void *  obj,
char *  name,
const char *  value,
const char *  def 
)

Use of this function should be avoided where possible. It is not possible to explicitly indicate whether the caller is trying to create/lookup a regular text attribute or an HTML-like attribute. It is better to be explicit with your intent and instead call either agsafeset_text or agsafeset_html.

This function has the following behavior:

  1. If the attribute needs to be created (it did not already exist) and def was obtained from agstrdup_html, an HTML-like default attribute value is created.
  2. If the attribute needs to be created (it did not already exist) and def was not obtained from agstrdup_html, a regular text default attribute value is created. … then …
  1. If the value passed was obtained from agstrdup_html, an HTML-like attribute value is created/looked up. That is, the behavior is equivalent to a call to agsafeset_html.
  2. Otherwise, a regular text attribute value is created/looked up. That is, the behavior is equivalent to a call to agsafeset_text.
Parameters
objObject on which to set the attribute
nameName of the attribute to set
valueValue of the attribute to set
defOptional default to declare for the attribute

Definition at line 586 of file attr.c.

References agattr_html(), agattr_text(), aghtmlstr(), agraphof(), agstrbind_html(), AGTYPE, agxset(), agxset_html(), graph(), and NULL.

Referenced by addEdgeGraphics(), addEdgeGraphics(), addEdgeLabelGraphics(), addEdgeLabelGraphics(), addEdgePos(), addEdgePos(), addNodeGraphics(), addNodeGraphics(), addNodeLabelGraphics(), addNodeLabelGraphics(), addRevEdge(), gvLayout(), main(), main(), unknown(), unknown(), and xdot_end_graph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agsafeset_html()

int agsafeset_html ( void *  obj,
char *  name,
const char *  value,
const char *  def 
)

The attribue set by this function is an HTML-like attribute. See agsafeset_text for the equivalent for a regular text attribute.

Parameters
objObject on which to set the attribute
nameName of the attribute to set
valueValue of the attribute to set
defOptional default to declare for the attribute

Definition at line 578 of file attr.c.

References agattr_html(), agraphof(), AGTYPE, agxset_html(), and NULL.

Here is the call graph for this function:

◆ agsafeset_text()

int agsafeset_text ( void *  obj,
char *  name,
const char *  value,
const char *  def 
)

The attribue set by this function is a regular text attribute. See agsafeset_html for the equivalent for an HTML-like attribute.

Parameters
objObject on which to set the attribute
nameName of the attribute to set
valueValue of the attribute to set
defOptional default to declare for the attribute

Definition at line 569 of file attr.c.

References agattr_text(), agraphof(), AGTYPE, agxset(), and NULL.

Here is the call graph for this function:

◆ agset()

int agset ( void *  obj,
char *  name,
const char *  value 
)

Definition at line 499 of file attr.c.

References aghtmlstr(), agraphof(), agset_html(), agset_text(), agstrbind_html(), and NULL.

Referenced by attach_attrs_and_arrows(), cloneAttrs(), cloneNode(), color(), doApply(), make_flat_adj_edges(), patchwork_init_node(), setSeed(), and twopi_layout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agset_html()

int agset_html ( void *  obj,
char *  name,
const char *  value 
)

Definition at line 518 of file attr.c.

References agset_().

Referenced by agset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agset_text()

int agset_text ( void *  obj,
char *  name,
const char *  value 
)

Definition at line 514 of file attr.c.

References agset_().

Referenced by agset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agxget()

◆ agxset()

int agxset ( void *  obj,
Agsym_t sym,
const char *  value 
)

◆ agxset_html()

int agxset_html ( void *  obj,
Agsym_t sym,
const char *  value 
)

Definition at line 565 of file attr.c.

References agxset_().

Referenced by agcopyattr(), agsafeset(), agsafeset_html(), agset_(), agxset(), applyattrs(), and applyattrs().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ agxset_text()

int agxset_text ( void *  obj,
Agsym_t sym,
const char *  value 
)

Definition at line 561 of file attr.c.

References agxset_().

Referenced by agset_(), and agxset().

Here is the call graph for this function:
Here is the caller graph for this function: