Hello, I'm a newcomer to Python and I don't understand the way I could get drawn some properties for edges or vertices. The documentation says: vprops : dict (default: {}) Additional vertex properties, as a dictionary. The keys are the property names, and the values must be convertible to string, or vertex property maps, with values convertible to strings. But I guess that I'm missing something with Python as I only get drawn a text description of the object. Foe example: If I try a sentence like graph_draw(g, eprops={"label": g.edge_properties}, output="two-nodes2.png") it draws obviously the label for that object which is: {'occ': <PropertyMap object with key type 'Edge' and value type 'int32_t', for Graph 0x2f6dcd0, at 0x2f6de10>} But I don't understand which parameter I should pass to graph_draw in order to get the desired outcome. Could you provide a mini-example of drawing a small graph with properties on edges/vertices? This could also be added to the Quick tutorial. Thank you in advance peers. Regards. -- 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 Gustav, On 06/15/2011 10:39 PM, Gustav wrote:
If I try a sentence like
graph_draw(g, eprops={"label": g.edge_properties}, output="two-nodes2.png")
it draws obviously the label for that object which is:
{'occ': <PropertyMap object with key type 'Edge' and value type 'int32_t', for Graph 0x2f6dcd0, at 0x2f6de10>}
But I don't understand which parameter I should pass to graph_draw in order to get the desired outcome.
The attribute g.edge_properties is a dictionary of internal property maps. What you want to so is to pass some property map in isolation, not all of them. What you want to pass depends of course of what you want to do, which is not very clear to me. Suppose, for instance, you have a property map which has numeric value for each edge, which is called "edge_prop", which is created as such: edge_prop = g.new_edge_property("double") for e in g.edges(): edge_prop[e] = random() # fill with random values If you want to draw a label on top of the edges with these values you would do: graph_draw(g, eprops={"label": edge_prop}) If, instead you want it to represent the length of the edge, you would do something like: graph_draw(g, eprops={"len": edge_prop}) Take a look at http://www.graphviz.org/doc/info/attrs.html for all possible properties one can set. Note that for vertex and edge color, as well as size, graph_draw() provides direct parameters, so one does not need to pass anything to eprops or vprops. Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Hello, Thank you Tiago. I think I got it now. I was misunderstanding those "label"/"len" parametres as something within the dictionary when in fact they are refering to properties in GraphViz. I'll make some tests and if I'll have some doubts yet I'll be back. Thanks again. Regards. -- 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)
-
Gustav -
Tiago de Paula Peixoto