def matching_ind_und(CIJ0):
    '''
    M0 = MATCHING_IND_UND(CIJ) computes matching index for undirected
    graph specified by adjacency matrix CIJ. Matching index is a measure of
    similarity between two nodes' connectivity profiles (excluding their
    mutual connection, should it exist).

    Parameters
    ----------
    CIJ : NxN np.ndarray
        undirected adjacency matrix

    Returns
    -------
    M0 : NxN np.ndarray
        matching index matrix
    '''
    K = np.sum(CIJ0, axis=0)
    n = len(CIJ0)
    R = (K != 0)
    N = np.sum(R)
    xR, = np.where(R == 0)
    CIJ = np.delete(np.delete(CIJ0, xR, axis=0), xR, axis=1)
    I = np.logical_not(np.eye(N))
    M = np.zeros((N, N))

    for i in range(N):
        c1 = CIJ[i, :]
        use = np.logical_or(c1, CIJ)
        use[:, i] = 0
        use *= I

        ncon1 = c1 * use
        ncon2 = c1 * CIJ
        ncon = np.sum(ncon1 + ncon2, axis=1)
        print(ncon)

        M[:, i] = 2 * np.sum(np.logical_and(ncon1, ncon2), axis=1) / ncon

    M *= I
    M[np.isnan(M)] = 0
    M0 = np.zeros((n, n))
    yR, = np.where(R)
    M0[np.ix_(yR, yR)] = M
    return M0
M0 = MATCHING_IND_UND(CIJ) computes matching index for undirected
    graph specified by adjacency matrix CIJ. Matching index is a measure of
    similarity between two nodes' connectivity profiles (excluding their
    mutual connection, should it exist).

    Parameters
    ----------
    CIJ : NxN np.ndarray
        undirected adjacency matrix

    Returns
    -------
    M0 : NxN np.ndarray
        matching index matrix