Hi and seasons greetings to everybody! I am displaying graphs with graphviz_draw To obtain a different color for every type of vertex I use argument vcolor=g.vp["typev"] where the vertex property "typev" is of type int, it works just fine My problem is with edge colors: I have an edge property called g.ep["typee"] but it is of type vector<short>, in fact it is a list of three elements and it is the second one that I need to define the color of every edge. I tried ecolor=g.ep["typee"][1] and it didn't worked (this was predictable since one has to apply g.ep["typee"] to an edge first and then take the second element to get an integer). I also tried ecolor=lambda x: g.ep["typee"][x][1] and ecolor=(lambda x: g.ep["typee"][x][1]) none of them worked. How can I obtain what I need? Thanks in advance Yannis -- ------------------------------------------------------- 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 27.12.2015 22:22, Yannis Haralambous wrote:
I am displaying graphs with graphviz_draw
To obtain a different color for every type of vertex I use argument
*vcolor=g.vp["typev"] *
where the vertex property "typev" is of type int, it works just fine
My problem is with edge colors: I have an edge property called g.ep["typee"] but it is of type vector<short>, in fact it is a list of three elements and it is the second one that I need to define the color of every edge.
I tried
*ecolor=g.ep["typee"][1]*
and it didn't worked (this was predictable since one has to apply g.ep["typee"] to an edge first and then take the second element to get an integer). I also tried
*ecolor=lambda x: g.ep["typee"][x][1]* * * and * * *ecolor=(lambda x: g.ep["typee"][x][1]) * none of them worked. How can I obtain what I need?
You need to create a new property map of the correct type. I.e. ecolor = g.new_edge_property("int") for e in g.edges: ecolor[e] = g.ep["typee"][e][1] graphviz_draw(g, ecolor=ecolor) Alternatively, you may use "ungroup_vector_property()": ecolor = ungroup_vector_property(g.ep["typee"], [1])[0] graphviz_draw(g, ecolor=ecolor) Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Thanks for the quick reply but it didn't worked.
Le 27 déc. 2015 à 23:55, Tiago de Paula Peixoto <tiago@skewed.de> a écrit :
Alternatively, you may use "ungroup_vector_property()":
ecolor = ungroup_vector_property(g.ep["typee"], [1])[0] graphviz_draw(g, ecolor=ecolor)
I got the following error message: Traceback (most recent call last): File "build-graph.py", line 595, in <module> ecolor = ungroup_vector_property(g.ep["typee"], [1])[0] File "/usr/local/lib/python2.7/site-packages/graph_tool/__init__.py", line 1035, in ungroup_vector_property _check_prop_vector(vprop, name="vprop", scalar=False) File "/usr/local/lib/python2.7/site-packages/graph_tool/__init__.py", line 915, in _check_prop_vector (" floating" if floating else ""))) ValueError: property map 'vprop' is not of vector type. -- ------------------------------------------------------- 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 28.12.2015 01:08, Yannis Haralambous wrote:
Thanks for the quick reply but it didn't worked.
Le 27 déc. 2015 à 23:55, Tiago de Paula Peixoto <tiago@skewed.de> a écrit :
Alternatively, you may use "ungroup_vector_property()":
ecolor = ungroup_vector_property(g.ep["typee"], [1])[0] graphviz_draw(g, ecolor=ecolor)
I got the following error message:
Traceback (most recent call last): File "build-graph.py", line 595, in <module> ecolor = ungroup_vector_property(g.ep["typee"], [1])[0] File "/usr/local/lib/python2.7/site-packages/graph_tool/__init__.py", line 1035, in ungroup_vector_property _check_prop_vector(vprop, name="vprop", scalar=False) File "/usr/local/lib/python2.7/site-packages/graph_tool/__init__.py", line 915, in _check_prop_vector (" floating" if floating else ""))) ValueError: property map 'vprop' is not of vector type.
You said your property was of type "vector<short>". This error message says it isn't. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
participants (3)
-
Tiago de Paula Peixoto -
Yannis Haralambous -
Yannis Haralambous