Hi Jelle,

On 01/09/2013 10:43 AM, jcjveraa wrote:
> Hey there,
>
> I have a list of labels which I'd like to attach to the rendering of a
> graph. I can get a PDF with labels on the edges using:
>
> import graph_tool.all as gt
> [[[make graph g with vertices and edges]]]
> gt.graphviz_draw(g, eprops={"label":g.edge_index},output="out.pdf")
> #produces a graph with edges labeled 0 to n-1
> gt.graphviz_draw(g, eprops={"label":"test label"},output="out.pdf")
> #produces a graph with all edges labeled "test label", so labeling with
> strings is possible
>
> What I'd like to do is to use those edge_index values as index for an
arary
> containing my labels as strings to be placed in the graph.
>
> eprops={"label":labelStrings[i]} # where i is equal to the numeric
value of
> the edge_index
>
> How would I do that?

All you have to do is to create an edge property map with a value type
'string':

label = g.new_edge_property("string")

e = g.add_edge(s, t)
label[e] = "label for new edge"

graphviz_draw(g, eprops={"label": label})

> Perhaps if I could see what a 'vector' is as defined here I might be
able to
> figure it out, but it's not specified:
>
http://projects.skewed.de/graph-tool/doc/graph_tool.html#graph_tool.PropertyMap

A vector in this context is a C++ vector which is reflected into
python. This refers to the type the property map stores, rather than the
property map itself.

Cheers,
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