Query regarding graph layout in graph-tool
Hi All, I am very new to graph-tool and looking into its documentation. I've been playing with the F-R algorithm with weighted edges to layout time series data. I want to know is it possible in graph-tool to nominate a node to be the centre of the graph and have the layout chose the distance of near by nodes to be directly proportional to the strength of the edge weight. The more two nodes correlate, the closer together they are. Any help is appreciated. Thanks, Kapil PS: If graph-tool is not yet capable of nominating/fixing a particular node, is there any other python graph package which can do so? -- Kapil Gupta Phone: +91-9312505395 Alt Email: kapilgupta.iit@gmail.com
Hi Kapil, Sorry for the late reply. On 03/17/2011 10:50 AM, kapil gupta wrote:
I want to know is it possible in graph-tool to nominate a node to be the centre of the graph and have the layout chose the distance of near by nodes to be directly proportional to the strength of the edge weight. The more two nodes correlate, the closer together they are.
I'm not sure if I understand precisely what you want, but you can definitely "pin down" the position of a subset of the vertices, and let the layout modify only the remaining ones. You can also set a "len" edge property, which defines the preferred edge length for the layout. Take a look at the full graphviz options at http://www.graphviz.org/content/attrs To use these options with graph-tool, you should do something like: len = g.new_edge_property("double") len.a = 1.0 / weight.a # your edge weight pin = g.new_vertex_property("bool") pin[root] = True # root is the vertex which should be pinned down graph_draw(g, eprops={"len": len}, vprops={"pin": pin}) I hope this helps! Cheers, Tiago -- Tiago de Paula Peixoto <tiago@skewed.de>
Thanks a lot Tiago, that was helpful :). On Sat, Mar 19, 2011 at 11:24 PM, Tiago de Paula Peixoto <tiago@skewed.de>wrote:
Hi Kapil,
Sorry for the late reply.
On 03/17/2011 10:50 AM, kapil gupta wrote:
I want to know is it possible in graph-tool to nominate a node to be the centre of the graph and have the layout chose the distance of near by nodes to be directly proportional to the strength of the edge weight. The more two nodes correlate, the closer together they are.
I'm not sure if I understand precisely what you want, but you can definitely "pin down" the position of a subset of the vertices, and let the layout modify only the remaining ones. You can also set a "len" edge property, which defines the preferred edge length for the layout. Take a look at the full graphviz options at http://www.graphviz.org/content/attrs
To use these options with graph-tool, you should do something like:
len = g.new_edge_property("double") len.a = 1.0 / weight.a # your edge weight pin = g.new_vertex_property("bool") pin[root] = True # root is the vertex which should be pinned down graph_draw(g, eprops={"len": len}, vprops={"pin": pin})
I hope this helps!
Cheers, Tiago
-- Tiago de Paula Peixoto <tiago@skewed.de>
_______________________________________________ graph-tool mailing list graph-tool@skewed.de http://lists.skewed.de/mailman/listinfo/graph-tool
-- Kapil Gupta Phone: +91-9312505395 Alt Email: kapilgupta.iit@gmail.com
participants (2)
-
kapil gupta -
Tiago de Paula Peixoto