Check if permutation of DAG is in topological order