topo sort & etc