This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.


spectral_layout(G, dim=2, weight='weight', scale=1)[source]

Position nodes using the eigenvectors of the graph Laplacian.

Parameters :

G : NetworkX graph

dim : int

Dimension of layout

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 : float

Scale factor for positions

Returns :

dict :

A dictionary of positions keyed by node


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

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


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