def supernodes(par, post, colcount):
    """
    Find supernodes.

    ARGUMENTS
    par       parent array

    post      array with post ordering

    colcount  array with column counts

    RETURNS
    snode     array with supernodes; snode[snptr[k]:snptr[k+1]] contains
              the indices of supernode k

    snptr     pointer array; snptr[k] is the index of the representative
              vertex of supernode k in the snode array

    snpar     supernodal parent structure 
    """
    snpar, flag = pothen_sun(par, post, colcount)
    n = len(par)
    N = len(snpar)

    snode = matrix(0, (n,1))
    snptr = matrix(0, (N+1,1))

    slist = [[] for i in range(n)]
    for i in range(n):
        f = flag[i]
        if f < 0:
            slist[i].append(i)
        else:
            slist[f].append(i)

    k = 0; j = 0
    for i,sl in enumerate(slist):
        nsl = len(sl)
        if nsl > 0:
            snode[k:k+nsl] = matrix(sl)
            snptr[j+1] = snptr[j] + nsl
            k += nsl
            j += 1
        
    return snode, snptr, snpar
Find supernodes.

    ARGUMENTS
    par       parent array

    post      array with post ordering

    colcount  array with column counts

    RETURNS
    snode     array with supernodes; snode[snptr[k]:snptr[k+1]] contains
              the indices of supernode k

    snptr     pointer array; snptr[k] is the index of the representative
              vertex of supernode k in the snode array

    snpar     supernodal parent structure