I'm trying to update some old code which used to work with Graphviz 2.26 and iterated over all the nodes of a graph and did something with their names:
for (Agnode_t *n = agfstnode(graph); n; n = agnxtnode(graph, n)) {
... use n->name ...
}
However in recent (2.30+?) versions of Graphviz, cgraph library is used for node representation and it doesn't have name
field in its Agnode_t
struct.
I know about agnode()
function which allows to lookup the node by name, but there doesn't seem to be any function to go in the other direction. Am I missing something or is there really no way to access the name of the existing node with cgraph?
You can use the function agnameof
, which is listed in the "Generic Objects" section of the cgraph
manpage:
char *agnameof(void*);