Hi, Following this example <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Drawing-properties-newbie-question-td3069446.html> , I try to draw the weight values on a graph as follow: import graph_tool.all as gt import numpy as np mG = gt.Graph(directed = False) #Defining properties edgeP_image = mG.new_edge_property("object") edgeP_weight = mG.new_edge_property("double") vertexP_image= mG.new_edge_property("object") mG.edge_properties["image"] = edgeP_image mG.edge_properties["weight"] = edgeP_weight #Building a multigraphgraph v1 = mG.add_vertex() v2 = mG.add_vertex() v3 = mG.add_vertex() mG.add_edge(v1,v1) mG.add_edge(v1,v2) mG.add_edge(v1,v2) mG.add_edge(v2,v3) mG.add_edge(v1,v3) print mG.list_properties() # How to set the edge weight? e1 = mG.edge(v1,v2) print e1.target() edgeP_weight[e1]=5 np.random.seed(42) for e in mG.edges(): edgeP_weight[e]=np.random.randint(1,20) print e gt.graph_draw(mG, eprops={"len": edgeP_weight}, output_size=(260, 260)) And this code produces the following graph: <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/n4025568/multigraph_noweight.png> I tried different variations without success: {"double": edgeP_weight} {"weight": edgeP_weight} Best regards Jean-Patrick -- 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.
On 06/13/2014 03:08 PM, jean-patrick wrote:
Hi,
Following this example <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/Drawing-properties-newbie-question-td3069446.html> , I try to draw the weight values on a graph as follow:
import graph_tool.all as gt import numpy as np mG = gt.Graph(directed = False)
#Defining properties edgeP_image = mG.new_edge_property("object") edgeP_weight = mG.new_edge_property("double") vertexP_image= mG.new_edge_property("object")
mG.edge_properties["image"] = edgeP_image mG.edge_properties["weight"] = edgeP_weight
#Building a multigraphgraph v1 = mG.add_vertex() v2 = mG.add_vertex() v3 = mG.add_vertex() mG.add_edge(v1,v1) mG.add_edge(v1,v2) mG.add_edge(v1,v2) mG.add_edge(v2,v3) mG.add_edge(v1,v3)
print mG.list_properties() # How to set the edge weight? e1 = mG.edge(v1,v2) print e1.target()
edgeP_weight[e1]=5
np.random.seed(42) for e in mG.edges(): edgeP_weight[e]=np.random.randint(1,20) print e gt.graph_draw(mG, eprops={"len": edgeP_weight}, output_size=(260, 260))
You should use: gt.graph_draw(mG, edge_pen_width=edgeP_weight, output_size=(260, 260)) Take a careful look at the documentation available for the graph_draw() function, which explains everything. Best, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Thanks a lot, Jean-Patrick <http://main-discussion-list-for-the-graph-tool-project.982480.n3.nabble.com/file/n4025580/multigraph_weighted.png> -- 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)
-
jean-patrick -
Tiago de Paula Peixoto