Graphviz vertex/edge properties

Sorry for disturbing again, but I’m trying to draw a graph (with graphviz) with labels on vertices and on edges.
I saw in the documentation that vprops and eprops are Python attributes with values that are dictionaries containing
key-value pairs, where key is a graphviz attribute and value is either a string or a property map.

So I tried the following:

graphviz_draw(g, vcolor=typev, vprops={label: labelv}, eprops={label: labele}, output=fname+".pdf »)

where label is a graphviz property (as explained in http://www.graphviz.org/doc/info/attrs.html#d:label)
and labelv and labele are property maps defined as

labelv = g.new_vertex_property("string")
labele = g.new_edge_property("string »)

This doesn’t work and I get the error message

Traceback (most recent call last):
  File "build-graph.py", line 459, in <module>
    graphviz_draw(g, vcolor=typev, vprops={label: labelv}, eprops={label: labele}, output=fname+".pdf")
NameError: name 'label' is not defined

But label is indeed a graphviz property, no doubt upon that. What am I doing wrong?

Thanks in advance

Yannis

attachment.html (3.85 KB)

Hi Yannis,

As the error message states, that is happening within your code at line
459. It isn't going down to graph_tool or graphviz.

And it is a python NameError for 'label', so you're simply using a name
'label' that is not defined.

You can't define a dictionary using as argument something that is not
defined.

In this case it is your dictionary definition that should have quoted the
name so it becomes a string.

Try this instead:

graphviz_draw(g, vcolor=typev, vprops={"label": labelv}, eprops={"label":
labele}, output=fname+".pdf")

Good luck,

ale

attachment.html (4.25 KB)