I would like to combine an existing vertex property (called labelv and of type string) and the vertex index to obtain a new vertex property, to use inside graphviz_draw. Here is what I wrote:
mylabel = g.new_vertex_property("string")
for v in g.vertices():
g.vp['mylabel'][v] = str(g.vp['labelv'][v])+" ("+str(g.vertex_index[v])+")"
graphviz_draw(g, vcolor=typev, gprops={"scalexy": "scalexy"}, \
vprops={"xlabel": mylabel, "fontsize": 6, "fixedsize": True, \
"labelloc": "t"}, eprops={"label": labele, "fontsize": 4, \
"dir": "forward"}, output=fname+".pdf »)
But it doens’t work. (I get the error message:
Traceback (most recent call last):
File "build-graph.py", line 380, in <module>
g.vp['mylabel'][v] = str(g.vp['labelv'][v])+" ("+str(g.vertex_index[v])+")"
File "/usr/local/lib/python2.7/site-packages/graph_tool/__init__.py", line 1346, in __getitem__
return self.properties[(self.t, key)]
KeyError: ('v', 'mylabel’)
Could you tell me what I’m doing wrong?
Thanks!
attachment.html (2.87 KB)