Algorithm for finding a Hamiltonian Path in a DAG
You can first topologically sort the DAG (every DAG can be topologically sorted) in O(n+m). Once this is done, you know that edge go from lower index vertices to higher. This means that there exists a Hamiltonian path if and only if there are edge between consecutive vertices, e.g. (1,2), (2,3), …, (n-1,n). (This is … Read more