networkx.drawing.layout.random_layout¶
-
random_layout(G, center=None, dim=2, seed=None)[source]¶ Position nodes uniformly at random in the unit square.
For every node, a position is generated by choosing each of dim coordinates uniformly at random on the interval [0.0, 1.0).
NumPy (http://scipy.org) is required for this function.
- Parameters
G (
NetworkX graphorlistofnodes) – A position will be assigned to every node in G.center (
array-likeorNone) – Coordinate pair around which to center the layout.dim (
int) – Dimension of layout.seed (
int,RandomState instanceorNone optional (default=None)) – Set the random state for deterministic node layouts. If int,seedis the seed used by the random number generator, if numpy.random.RandomState instance,seedis the random number generator, if None, the random number generator is the RandomState instance used by numpy.random.
- Returns
pos – A dictionary of positions keyed by node
- Return type
Examples
>>> G = nx.lollipop_graph(4, 3) >>> pos = nx.random_layout(G)