 It is also possible to check whether a given directed graph is a DAG in linear time , either by attempting to find a topological ordering and then testing for each edge whether the resulting ordering is valid or alternatively , for some topological sorting algorithms , by <unk> that the algorithm successfully orders all the vertices without meeting an error condition . 
