Update topological sort with DAG