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

spectral_ordering
(G, weight='weight', normalized=False, tol=1e08, method='tracemin')[source]¶ Compute the spectral_ordering of a graph.
The spectral ordering of a graph is an ordering of its nodes where nodes in the same weakly connected components appear contiguous and ordered by their corresponding elements in the Fiedler vector of the component.
Parameters:  G (NetworkX graph) – A graph.
 weight (object, optional) – The data key used to determine the weight of each edge. If None, then each edge has unit weight. Default value: None.
 normalized (bool, optional) – Whether the normalized Laplacian matrix is used. Default value: False.
 tol (float, optional) – Tolerance of relative residual in eigenvalue computation. Default value: 1e8.
 method (string, optional) –
Method of eigenvalue computation. It should be one of ‘tracemin’ (TraceMIN), ‘lanczos’ (Lanczos iteration) and ‘lobpcg’ (LOBPCG). Default value: ‘tracemin’.
The TraceMIN algorithm uses a linear system solver. The following values allow specifying the solver to be used.
Value Solver ‘tracemin_pcg’ Preconditioned conjugate gradient method ‘tracemin_chol’ Cholesky factorization ‘tracemin_lu’ LU factorization
Returns: spectral_ordering – Spectral ordering of nodes.
Return type: NumPy array of floats.
Raises: NetworkXError
– If G is empty.Notes
Edge weights are interpreted by their absolute values. For MultiGraph’s, weights of parallel edges are summed. Zeroweighted edges are ignored.
To use Cholesky factorization in the TraceMIN algorithm, the
scikits.sparse
package must be installed.See also
laplacian_matrix()