 Every directed acyclic graph has a topological ordering , an ordering of the vertices such that the starting endpoint of every edge occurs earlier in the ordering than the ending endpoint of the edge . The existence of such an ordering can be used to characterize DAGs : a directed graph is a DAG if and only if it has a topological ordering . In general , this ordering is not unique ; a DAG has a unique topological ordering if and only if it has a directed path containing all the vertices , in which case the ordering is the same as the order in which the vertices appear in the path . 
