 A topological ordering of a directed graph is an ordering of its vertices into a sequence , such that for every edge the start vertex of the edge occurs earlier in the sequence than the ending vertex of the edge . A graph that has a topological ordering cannot have any cycles , because the edge into the earliest vertex of a cycle would have to be oriented the wrong way . Therefore , every graph with a topological ordering is acyclic . Conversely , every directed acyclic graph has a topological ordering . Therefore , this property can be used as an alternative definition of the directed acyclic graphs : they are exactly the graphs that have topological orderings . 
