code: def spectral_ordering(
      G,
      weight="weight",
      normalized=False,
      tol=1e-8,
      method="tracemin_pcg",
      seed=None,
  ):
      """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 (default: None)
          The data key used to determine the weight of each edge. If None, then
          each edge has unit weight.
  
      normalized : bool, optional (default: False)
          Whether the normalized Laplacian matrix is used.
  
      tol : float, optional (default: 1e-8)
          Tolerance of relative residual in eigenvalue computation.
  
      method : string, optional (default: 'tracemin_pcg')
          Method of eigenvalue computation. It must be one of the tracemin
          options shown below (TraceMIN), 'lanczos' (Lanczos iteration)
          or 'lobpcg' (LOBPCG).
  
          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_lu'   LU factorization
          =============== ========================================
  
      seed : integer, random_state, or None (default)
          Indicator of random number generation state.
          See :ref:`Randomness<randomness>`.
  
      Returns
      -------
      spectral_ordering : NumPy array of floats.
          Spectral ordering of nodes.
  
      Raises
      ------
      NetworkXError
          If G is empty.
  
      Notes
      -----
      Edge weights are interpreted by their absolute values. For MultiGraph's,
      weights of parallel edges are summed. Zero-weighted edges are ignored.
  
      See Also
      --------
      laplacian_matrix
      """
      if len(G) == 0:
          raise nx.NetworkXError("graph is empty.")
      G = _preprocess_graph(G, weight)
  
      find_fiedler = _get_fiedler_func(method)
      order = []
      for component in nx.connected_components(G):
          size = len(component)
          if size > 2:
              L = nx.laplacian_matrix(G, component)
              x = (
                  None
                  if method != "lobpcg"
                  else _rcm_estimate(G, component)
              )
              sigma, fiedler = find_fiedler(L, x, normalized, tol, seed)
              sort_info = zip(fiedler, range(size), component)
              order.extend(u for x, c, u in sorted(sort_info))
          else:
              order.extend(component)
  
      return order
  
file_path: networkx/networkx/linalg/algebraicconnectivity.py
imports: from functools import partial
  import networkx
  from networkx.utils import not_implemented_for, np_random_state, reverse_cuthill_mckee_ordering
label_desc: Use image node_id 7 for calling a global function with example usage: spectral_ordering(G, weight, normalized, tol, method, seed) and returns: order