r"""Compute the total flux between reactant and product.

    Parameters
    ----------
    flux : (M, M) scipy.sparse matrix
        Matrix of flux values between pairs of states.
    A : array_like
        List of integer state labels for set A (reactant)

    Returns
    -------
    F : float
        The total flux between reactant and product

def total_flux(flux, A):
    r"""Compute the total flux between reactant and product.

    Parameters
    ----------
    flux : (M, M) scipy.sparse matrix
        Matrix of flux values between pairs of states.
    A : array_like
        List of integer state labels for set A (reactant)

    Returns
    -------
    F : float
        The total flux between reactant and product

    """
    X = set(np.arange(flux.shape[0]))  # total state space
    A = set(A)
    notA = X.difference(A)

    """Extract rows corresponding to A"""
    W = flux.tocsr()
    W = W[list(A), :]
    """Extract columns corresonding to X\A"""
    W = W.tocsc()
    W = W[:, list(notA)]

    F = W.sum()
    return F