[graph-tool] problem with draw.random_layout

Tiago de Paula Peixoto tiago at skewed.de
Tue May 10 13:33:29 CEST 2011

On 05/09/2011 05:03 PM, tamo wrote:
> Hi,
> it seems that I've a problem with graph_tool.draw.random_layout(g,
> shape=None, pos=None, dim=2) function.
> I wrote a script to load a graph from dot file then I was trying to assign a
> random position for each vertex in the space.
> I found that random_layout function could do that, but I doesn't work with
> me.

Indeed there is a problem with the random_layout() function. I've fixed
it, and committed the changes to the git version. Thanks for noticing

If you want just a quick way of obtaining a 2D random layout, you could
of course do something like:

    pos = g.new_vertex_property("vector<double>")
    for v in g.vertices():
        pos[v] = numpy.random.random(2)

Which generates random positions within a two-dimensional unit square.


Tiago de Paula Peixoto <tiago at skewed.de>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 554 bytes
Desc: OpenPGP digital signature
URL: <https://lists.skewed.de/pipermail/graph-tool/attachments/20110510/bce0994c/attachment.asc>

More information about the graph-tool mailing list