added topsort2 (sorry); it is a topsort that throws on cycle