@not_implemented_for('directed')
def fiedler_vector(G, weight='weight', normalized=False, tol=1e-08, method='tracemin_pcg'):
    "Return the Fiedler vector of a connected undirected graph.\n\n    The Fiedler vector of a connected undirected graph is the eigenvector\n    corresponding to the second smallest eigenvalue of the Laplacian matrix of\n    of the graph.\n\n    Parameters\n    ----------\n    G : NetworkX graph\n        An undirected graph.\n\n    weight : object, optional (default: None)\n        The data key used to determine the weight of each edge. If None, then\n        each edge has unit weight.\n\n    normalized : bool, optional (default: False)\n        Whether the normalized Laplacian matrix is used.\n\n    tol : float, optional (default: 1e-8)\n        Tolerance of relative residual in eigenvalue computation.\n\n    method : string, optional (default: 'tracemin_pcg')\n        Method of eigenvalue computation. It must be one of the tracemin\n        options shown below (TraceMIN), 'lanczos' (Lanczos iteration)\n        or 'lobpcg' (LOBPCG).\n\n        The TraceMIN algorithm uses a linear system solver. The following\n        values allow specifying the solver to be used.\n\n        =============== ========================================\n        Value           Solver\n        =============== ========================================\n        'tracemin_pcg'  Preconditioned conjugate gradient method\n        'tracemin_chol' Cholesky factorization\n        'tracemin_lu'   LU factorization\n        =============== ========================================\n\n    Returns\n    -------\n    fiedler_vector : NumPy array of floats.\n        Fiedler vector.\n\n    Raises\n    ------\n    NetworkXNotImplemented\n        If G is directed.\n\n    NetworkXError\n        If G has less than two nodes or is not connected.\n\n    Notes\n    -----\n    Edge weights are interpreted by their absolute values. For MultiGraph's,\n    weights of parallel edges are summed. Zero-weighted edges are ignored.\n\n    To use Cholesky factorization in the TraceMIN algorithm, the\n    :samp:`scikits.sparse` package must be installed.\n\n    See Also\n    --------\n    laplacian_matrix\n    "
    if (len(G) < 2):
        raise nx.NetworkXError('graph has less than two nodes.')
    G = _preprocess_graph(G, weight)
    if (not nx.is_connected(G)):
        raise nx.NetworkXError('graph is not connected.')
    if (len(G) == 2):
        return array([1.0, (- 1.0)])
    find_fiedler = _get_fiedler_func(method)
    L = nx.laplacian_matrix(G)
    x = (None if (method != 'lobpcg') else _rcm_estimate(G, G))
    (sigma, fiedler) = find_fiedler(L, x, normalized, tol)
    return fiedler
Return the Fiedler vector of a connected undirected graph.

The Fiedler vector of a connected undirected graph is the eigenvector
corresponding to the second smallest eigenvalue of the Laplacian matrix of
of the graph.

Parameters
----------
G : NetworkX graph
    An undirected 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_chol' Cholesky factorization
    'tracemin_lu'   LU factorization
    =============== ========================================

Returns
-------
fiedler_vector : NumPy array of floats.
    Fiedler vector.

Raises
------
NetworkXNotImplemented
    If G is directed.

NetworkXError
    If G has less than two nodes or is not connected.

Notes
-----
Edge weights are interpreted by their absolute values. For MultiGraph's,
weights of parallel edges are summed. Zero-weighted edges are ignored.

To use Cholesky factorization in the TraceMIN algorithm, the
:samp:`scikits.sparse` package must be installed.

See Also
--------
laplacian_matrix
@not_implemented_for('directed')
def fiedler_vector(G, weight='weight', normalized=False, tol=1e-08, method='tracemin_pcg'):
    "Return the Fiedler vector of a connected undirected graph.\n\n    The Fiedler vector of a connected undirected graph is the eigenvector\n    corresponding to the second smallest eigenvalue of the Laplacian matrix of\n    of the graph.\n\n    Parameters\n    ----------\n    G : NetworkX graph\n        An undirected graph.\n\n    weight : object, optional (default: None)\n        The data key used to determine the weight of each edge. If None, then\n        each edge has unit weight.\n\n    normalized : bool, optional (default: False)\n        Whether the normalized Laplacian matrix is used.\n\n    tol : float, optional (default: 1e-8)\n        Tolerance of relative residual in eigenvalue computation.\n\n    method : string, optional (default: 'tracemin_pcg')\n        Method of eigenvalue computation. It must be one of the tracemin\n        options shown below (TraceMIN), 'lanczos' (Lanczos iteration)\n        or 'lobpcg' (LOBPCG).\n\n        The TraceMIN algorithm uses a linear system solver. The following\n        values allow specifying the solver to be used.\n\n        =============== ========================================\n        Value           Solver\n        =============== ========================================\n        'tracemin_pcg'  Preconditioned conjugate gradient method\n        'tracemin_chol' Cholesky factorization\n        'tracemin_lu'   LU factorization\n        =============== ========================================\n\n    Returns\n    -------\n    fiedler_vector : NumPy array of floats.\n        Fiedler vector.\n\n    Raises\n    ------\n    NetworkXNotImplemented\n        If G is directed.\n\n    NetworkXError\n        If G has less than two nodes or is not connected.\n\n    Notes\n    -----\n    Edge weights are interpreted by their absolute values. For MultiGraph's,\n    weights of parallel edges are summed. Zero-weighted edges are ignored.\n\n    To use Cholesky factorization in the TraceMIN algorithm, the\n    :samp:`scikits.sparse` package must be installed.\n\n    See Also\n    --------\n    laplacian_matrix\n    "
    if (len(G) < 2):
        raise nx.NetworkXError('graph has less than two nodes.')
    G = _preprocess_graph(G, weight)
    if (not nx.is_connected(G)):
        raise nx.NetworkXError('graph is not connected.')
    if (len(G) == 2):
        return array([1.0, (- 1.0)])
    find_fiedler = _get_fiedler_func(method)
    L = nx.laplacian_matrix(G)
    x = (None if (method != 'lobpcg') else _rcm_estimate(G, G))
    (sigma, fiedler) = find_fiedler(L, x, normalized, tol)
    return fiedler