def get_roots(adj):
    """ Returns all roots of a forest, described by an adjacency list.

    Parameters
    ----------
    adj: list
        an adjacency list

    Returns
    -------
    roots: list
        a list of roots, ascendingly sorted.

    """
    p = [-1] * len(adj)
    for i in range(len(adj)):
        for j in adj[i]:
            p[j] = i
    roots = []
    for i in range(len(adj)):
        if p[i] < 0:
            roots.append(i)
    return roots
