Using vertex index inside label
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! -- ------------------------------------------------------- Yannis Haralambous Professor Institut Mines-Télécom, Télécom Bretagne Computer Science Department UMR CNRS 6285 Lab-STICC Technopôle Brest Iroise CS 83818, 29238 Brest Cedex 3, France Email: yannis.haralambous@telecom-bretagne.eu Internet: http://perso.telecom-bretagne.eu/yannisharalambous/ ICBM address: 48°21'31.57"N 4°34'16.76"W Twitter: y_haralambous ------------------------------------------------------- ...the ball I threw while playing in the park has not yet reached the ground (Dylan Thomas) Es gab eine Zeit, wo ich nur ungern über Schubert sprechen, nur Nächtens den Bäumen und Sternen von ihm vorerzählen mögen. (Robert Schumann)
On 04.11.2015 00:43, Yannis Haralambous 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])+")"
Property maps do not automatically show up in the internal dictionary. Here it should be simply: mylabel = g.new_vertex_property("string") for v in g.vertices(): mylabel[v] = str(g.vp['labelv'][v])+" ("+str(g.vertex_index[v])+")" or alternatively, you should store the property in the dictionary first: g.vp["mylabel"] = mylabel Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (2)
-
Tiago de Paula Peixoto -
Yannis Haralambous