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?

attachment.html (856 Bytes)

Hi Kapil,

Sorry for the late reply.

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

Thanks a lot Tiago, that was helpful :).

attachment.html (2.28 KB)