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 <[email protected]>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
graph-tool mailing list
[email protected]
http://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to