random_layout

Contents

random_layout#

graph_tool.draw.random_layout(g, shape=None, pos=None, dim=2)[source]#

Performs a random layout of the graph.

Parameters:
gGraph

Graph to be used.

shapetuple or list (optional, default: None)

Rectangular shape of the bounding area. The size of this parameter must match dim, and each element can be either a pair specifying a range, or a single value specifying a range starting from zero. If None is passed, a square of linear size \(\sqrt{N}\) is used.

posVertexPropertyMap (optional, default: None)

Vector vertex property maps where the coordinates should be stored.

dimint (optional, default: 2)

Number of coordinates per vertex.

Returns:
posVertexPropertyMap

A vector-valued vertex property map with the coordinates of the vertices.

Notes

This algorithm has complexity \(O(V)\).

Examples

>>> g = gt.random_graph(100, lambda: (3, 3))
>>> shape = [[50, 100], [1, 2], 4]
>>> pos = gt.random_layout(g, shape=shape, dim=3)
>>> pos[g.vertex(0)].a
array([68.72700594,  1.03142919,  2.56812658])