Using the values of a property (eg. g.edge_index)
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? edge_index is a PropertyMap so that can't be used as index, but getting the values out as an array fails too so apparently it is of type vector or object. 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.Property... Being able to assign a label at the moment the edge is created with add_egde would work too and is even preferable in my situation, so that might be a solution too if I'd know how. Thanks, Jelle -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
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.Property... 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 <tiago@skewed.de>
Great, thanks for the quick response again! -- View this message in context: http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/... Sent from the Main discussion list for the graph-tool project mailing list archive at Nabble.com.
participants (2)
-
jcjveraa -
Tiago de Paula Peixoto