revision.c: generation-based topo-order algorithm