 Topological sorting is the algorithmic problem of finding a topological ordering of a given DAG . It can be solved in linear time . Kahn 's algorithm for topological sorting builds the vertex ordering directly . It maintains a list of vertices that have no incoming edges from other vertices that have not already been included in the partially constructed topological ordering ; initially this list consists of the vertices with no incoming edges at all . Then , it repeatedly adds one vertex from this list to the end of the partially constructed topological ordering , and checks whether its neighbors should be added to the list . The algorithm terminates when all vertices have been processed in this way . Alternatively , a topological ordering may be constructed by reversing a postorder numbering of a depth @-@ first search graph traversal . 
 Topological sorting <a href='drop_aux' title='1'><mark>is</mark></a>the algorithmic problem of finding a topological ordering of a given DAG . It can be solved in linear time . Kahn <a href='null_genetive' title='2'><mark>'s</mark></a>algorithm for topological sorting <a href='uninflect' title='3'><mark>builds</mark></a> the vertex ordering directly . It <a href='uninflect' title='4'><mark>maintains</mark></a> a list of vertices <a href='null_relcl' title='5'><mark>that</mark></a><a href='got' title='6'><mark>have</mark></a> no incoming edges from other vertices <a href='null_relcl' title='7'><mark>that</mark></a><a href='been_done' title='8'><mark>have</mark></a> not already been included in the partially constructed topological ordering ; initially this list <a href='uninflect' title='9'><mark>consists</mark></a> of the vertices with no incoming edges at all . Then , it repeatedly <a href='uninflect' title='10'><mark>adds</mark></a> one vertex from this list to the end of the partially constructed topological ordering , and checks whether its neighbors should be added to the list . The algorithm terminates when all vertices <a href='been_done' title='11'><mark>have</mark></a> been processed in this way . Alternatively , a topological ordering may be constructed by reversing a postorder numbering of a depth @-@ first search graph traversal . 
Topological sorting da algorithmic problem of finding a topological ordering of a given DAG . It can b solved in linear time . Kahn  algorithm fa topological sorting build the vertex ordering directly . It maintain a list of vertices got no incoming edges from other vertices done not already been included in tdapartially constructed topological ordering ; initially this list consist of thdaertices w no incoming edges at all . Then , it repeatedly add one vertex from this list to thedad of the datially constructed topological ordering , and checks whether its neighbors should be added to the lda . The algorithm terminates when all vertices done been processed in dis way . Alternatively , a topological ordering may bbconstructed by reversing a postorder numbering of a depth @-@ first search graph traversal .