(S, coloring_method=None)
return (weights, G, S, T)
Preprocess splitting functions.

    Parameters
    ----------
    S : csr_matrix
        Strength of connection matrix
    method : string
        Algorithm used to compute the vertex coloring:
            * 'MIS' - Maximal Independent Set
            * 'JP'  - Jones-Plassmann (parallel)
            * 'LDF' - Largest-Degree-First (parallel)

    Returns
    -------
    weights: ndarray
        Weights from a graph coloring of G
    S : csr_matrix
        Strength matrix with ones
    T : csr_matrix
        transpose of S
    G : csr_matrix
        union of S and T

    Notes
    -----
    Performs the following operations:
        - Checks input strength of connection matrix S
        - Replaces S.data with ones
        - Creates T = S.T in CSR format
        - Creates G = S union T in CSR format
        - Creates random weights
        - Augments weights with graph coloring (if use_color == True)
Preprocess splitting functions.
Preprocess splitting functions .
def _preprocess(S, coloring_method=None):
    """Preprocess splitting functions.

    Parameters
    ----------
    S : csr_matrix
        Strength of connection matrix
    method : string
        Algorithm used to compute the vertex coloring:
            * 'MIS' - Maximal Independent Set
            * 'JP'  - Jones-Plassmann (parallel)
            * 'LDF' - Largest-Degree-First (parallel)

    Returns
    -------
    weights: ndarray
        Weights from a graph coloring of G
    S : csr_matrix
        Strength matrix with ones
    T : csr_matrix
        transpose of S
    G : csr_matrix
        union of S and T

    Notes
    -----
    Performs the following operations:
        - Checks input strength of connection matrix S
        - Replaces S.data with ones
        - Creates T = S.T in CSR format
        - Creates G = S union T in CSR format
        - Creates random weights
        - Augments weights with graph coloring (if use_color == True)

    """
    if not isspmatrix_csr(S):
        raise TypeError('expected csr_matrix')

    if S.shape[0] != S.shape[1]:
        raise ValueError(f'expected square matrix, shape={S.shape}')

    N = S.shape[0]
    S = csr_matrix((np.ones(S.nnz, dtype='int8'), S.indices, S.indptr),
                   shape=(N, N))
    T = S.T.tocsr()  # transpose S for efficient column access

    G = S + T  # form graph (must be symmetric)
    G.data[:] = 1

    weights = np.ravel(T.sum(axis=1))  # initial weights
    # weights -= T.diagonal()          # discount self loops

    if coloring_method is None:
        weights = weights + np.random.rand(len(weights))
    else:
        coloring = vertex_coloring(G, coloring_method)
        num_colors = coloring.max() + 1
        weights = (weights + (np.random.rand(len(weights)) + coloring)
                   / num_colors)

    return (weights, G, S, T)
def _preprocess ( S , coloring_method = None ) : if not isspmatrix_csr ( S ) : raise TypeError ( 'expected csr_matrix' ) if S . shape [ 0 ] != S . shape [ 1 ] : raise ValueError ( f'expected square matrix, shape={S.shape}' ) N = S . shape [ 0 ] S = csr_matrix ( ( np . ones ( S . nnz , dtype = 'int8' ) , S . indices , S . indptr ) , shape = ( N , N ) ) T = S . T . tocsr ( ) # transpose S for efficient column access G = S + T # form graph (must be symmetric) G . data [ : ] = 1 weights = np . ravel ( T . sum ( axis = 1 ) ) # initial weights # weights -= T.diagonal()          # discount self loops if coloring_method is None : weights = weights + np . random . rand ( len ( weights ) ) else : coloring = vertex_coloring ( G , coloring_method ) num_colors = coloring . max ( ) + 1 weights = ( weights + ( np . random . rand ( len ( weights ) ) + coloring ) / num_colors ) return ( weights , G , S , T )