def _get_fiedler_func(method):
    'Return a function that solves the Fiedler eigenvalue problem.\n    '
    if (method == 'tracemin'):
        method = 'tracemin_pcg'
    if (method in ('tracemin_pcg', 'tracemin_chol', 'tracemin_lu')):

        def find_fiedler(L, x, normalized, tol):
            q = (1 if (method == 'tracemin_pcg') else min(4, (L.shape[0] - 1)))
            X = asmatrix(normal(size=(q, L.shape[0]))).T
            (sigma, X) = _tracemin_fiedler(L, X, normalized, tol, method)
            return (sigma[0], X[:, 0])
    elif ((method == 'lanczos') or (method == 'lobpcg')):

        def find_fiedler(L, x, normalized, tol):
            L = csc_matrix(L, dtype=float)
            n = L.shape[0]
            if normalized:
                D = spdiags((1.0 / sqrt(L.diagonal())), [0], n, n, format='csc')
                L = ((D * L) * D)
            if ((method == 'lanczos') or (n < 10)):
                (sigma, X) = eigsh(L, 2, which='SM', tol=tol, return_eigenvectors=True)
                return (sigma[1], X[:, 1])
            else:
                X = asarray(asmatrix(x).T)
                M = spdiags((1.0 / L.diagonal()), [0], n, n)
                Y = ones(n)
                if normalized:
                    Y /= D.diagonal()
                (sigma, X) = lobpcg(L, X, M=M, Y=asmatrix(Y).T, tol=tol, maxiter=n, largest=False)
                return (sigma[0], X[:, 0])
    else:
        raise nx.NetworkXError(("unknown method '%s'." % method))
    return find_fiedler
Return a function that solves the Fiedler eigenvalue problem.
def _get_fiedler_func(method):
    '\n    '
    if (method == 'tracemin'):
        method = 'tracemin_pcg'
    if (method in ('tracemin_pcg', 'tracemin_chol', 'tracemin_lu')):

        def find_fiedler(L, x, normalized, tol):
            q = (1 if (method == 'tracemin_pcg') else min(4, (L.shape[0] - 1)))
            X = asmatrix(normal(size=(q, L.shape[0]))).T
            (sigma, X) = _tracemin_fiedler(L, X, normalized, tol, method)
            return (sigma[0], X[:, 0])
    elif ((method == 'lanczos') or (method == 'lobpcg')):

        def find_fiedler(L, x, normalized, tol):
            L = csc_matrix(L, dtype=float)
            n = L.shape[0]
            if normalized:
                D = spdiags((1.0 / sqrt(L.diagonal())), [0], n, n, format='csc')
                L = ((D * L) * D)
            if ((method == 'lanczos') or (n < 10)):
                (sigma, X) = eigsh(L, 2, which='SM', tol=tol, return_eigenvectors=True)
                return (sigma[1], X[:, 1])
            else:
                X = asarray(asmatrix(x).T)
                M = spdiags((1.0 / L.diagonal()), [0], n, n)
                Y = ones(n)
                if normalized:
                    Y /= D.diagonal()
                (sigma, X) = lobpcg(L, X, M=M, Y=asmatrix(Y).T, tol=tol, maxiter=n, largest=False)
                return (sigma[0], X[:, 0])
    else:
        raise nx.NetworkXError(("unknown method '%s'." % method))
    return find_fiedler