def avg_diagonals(node, onodes):
    """Calculate the mean diagonals.
    
    Parameters
    ----------
    node : libpysal.cg._NodeCursor
        The target node in question.
    onodes : ist
        A list of ``libpysal.cg._NodeCursor`` objects.
    
    Returns
    -------
    diag_avg : float
        The mean diagonal distance of ``node`` and ``onodes``.
    
    """

    nidx = node.index
    sv = 0.0
    diag = 0.0
    memo_tab = {}

    for onode in onodes:
        k1 = (nidx, onode.index)
        k2 = (onode.index, nidx)

        if k1 in memo_tab:
            diag = memo_tab[k1]
        elif k2 in memo_tab:
            diag = memo_tab[k2]
        else:
            diag = node.rect.union(onode.rect).diagonal()
            memo_tab[k1] = diag

        sv += diag

    diag_avg = sv / len(onodes)

    return diag_avg