networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersRaisesReturnsBackRef
spiral_layout(G, scale=1, center=None, dim=2, resolution=0.35, equidistant=False)

Notes

This algorithm currently only works in two dimensions.

Parameters

G : NetworkX graph or list of nodes

A position will be assigned to every node in G.

scale : number (default: 1)

Scale factor for positions.

center : array-like or None

Coordinate pair around which to center the layout.

dim : int, default=2

Dimension of layout, currently only dim=2 is supported. Other dimension values result in a ValueError.

resolution : float, default=0.35

The compactness of the spiral layout returned. Lower values result in more compressed spiral layouts.

equidistant : bool, default=False

If True, nodes will be positioned equidistant from each other by decreasing angle further from center. If False, nodes will be positioned at equal angles from each other by increasing separation further from center.

Raises

ValueError

If dim != 2

Returns

pos : dict

A dictionary of positions keyed by node

Position nodes in a spiral layout.

Examples

>>> G = nx.path_graph(4)
... pos = nx.spiral_layout(G)
... nx.draw(G, pos=pos)
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

networkx.drawing.layout.spiral_layout

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /networkx/drawing/layout.py#949
type: <class 'function'>
Commit: