use digraph topo sort for building