networkx 2.8.2 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
spectral_layout(G, weight='weight', scale=1, center=None, dim=2)

Using the unnormalized Laplacian, the layout shows possible clusters of nodes which are an approximation of the ratio cut. If dim is the number of dimensions then the positions are the entries of the dim eigenvectors corresponding to the ascending eigenvalues starting from the second one.

Notes

Directed graphs will be considered as undirected graphs when positioning the nodes.

For larger graphs (>500 nodes) this will use the SciPy sparse eigenvalue solver (ARPACK).

Parameters

G : NetworkX graph or list of nodes

A position will be assigned to every node in G.

weight : string or None optional (default='weight')

The edge attribute that holds the numerical value used for the edge weight. If None, then all edge weights are 1.

scale : number (default: 1)

Scale factor for positions.

center : array-like or None

Coordinate pair around which to center the layout.

dim : int

Dimension of layout.

Returns

pos : dict

A dictionary of positions keyed by node

Position nodes using the eigenvectors of the graph Laplacian.

Examples

>>> G = nx.path_graph(4)
... pos = nx.spectral_layout(G)
See :

Back References

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

networkx.drawing.layout.spectral_layout networkx.drawing.nx_pylab.draw_spectral

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#763
type: <class 'function'>
Commit: