Re: [graphviz-interest] How to add and get custom attributes from dot-file?

Igor Chetverovod <[email protected]>
Newsgroups gmane.comp.video.graphviz
Message-ID <CAGTgnLeLNoU6oQhRaJzDJ5A0gFkigzzLm7LwDMEVGkVTighyAQ@mail.gmail.com>
2013/9/2, Emden R. Gansner <[email protected]>:
> On 9/2/13 5:54 AM, Igor Chetverovod wrote:
>> Hi all!
>> I am using  cgraph  for loading and parsing of a graph description
>> from a dot-file.
>> Now I need to add a custom  attributes to the nodes in the file and
>> have access to them after the  file reading to the memory. How can I
>> do that?
>>
>>
> Suppose you want nodes to carry the attribute "date". In your file, you
> would simply add
> another attribute a node:
>
>    node0 [color=red date="2 September 2013"]
>
> When you read the graph in, if np is a pointer (Agnode_t*) to node0,
> then you can just
> call agget(np, "date") and this will return the value of date stored in
> the node.
>
> Note that if no node has a date attribute, agget() will return NULL.
> Otherwise, it will return
> some non-NULL string value, either the value set to a specific node or
> the default date value,
> which well may be the empty string.
>
> If you want to add the attributes in your program, you first need to
> declare the attribute using
> agattr(). For example, you might do
>
>      s = agattr(g, AGNODE, "date", "");
>
> where g is a pointer to a graph and the last value specifies that the
> default date is the empty string"".
> After this, you can attach data values to nodes using
>
>      agset (np, "data", "1 January 2014");
>
> or, more efficiently,
>
>      agxset (np, s, "1 January 2014");
>
> Sometimes it is simpler to use
>
>      agsafeset (np, "data", "1 January 2014", "");
>
> which combines the attribute declaration and assignment.
>
>        Emden
>
>

Emdem, thank you.  This is what I need.

Best regards,
Igor
_______________________________________________
[email protected]
http://lists.research.att.com/mailman/listinfo/graphviz-interest
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.