2
$\begingroup$

I've been straggling a little proving the argument "a hamiltonian directed acyclic graph has a single topological sort".

This is pretty much the idea of what I've come along:

  • lets prove by contradiction. so lets assume a hamiltonian DAG has at least 2 topological sorts.
  • If there're few topological sorts - it means one of the following options:
  • either there're at least 2 vertices that aren't dependent. meaning both of these vertices could be with 0 in-degree. but it contradicts the fact that the graph is hamiltonian (there's a hamilton path in G)
  • either there exists a vertex that splits to 2 branches. such that the neighboring vertices could appear in different order in the topological sort. but it contradicts that the graph is hamiltonian because in such a case - after choosing a branch, we won't be able to visit the vertices of the second branch. however if we do have this possibility, we have come to a cycle that ends in the vertex that split to 2 branches. (contradiction to the graph being a DAG)
  • Finally we get contradiction to our assume - thus the original statement is correct.

Would appreciate your thoughts and suggestions about the idea of proof.

$\endgroup$
2
  • $\begingroup$ We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher. $\endgroup$
    – D.W.
    Commented Mar 22, 2017 at 22:08
  • $\begingroup$ @sgrmshrsm7, it's great that you want to edit the question to improve it. However, when making edits, we prefer that you try to improve as many aspects as possible. I'd discourage an edit that only changes the capitalization in the first word of the title, and makes no other change -- that bumps the question to the top of the front page and can take attention away from other worthy posts, and takes up time from three other community members to review the edit suggestion. See meta.stackexchange.com/q/74430/160917 and meta.stackexchange.com/a/82895/160917. $\endgroup$
    – D.W.
    Commented Mar 26, 2017 at 23:26

1 Answer 1

2
$\begingroup$

Let $G=(V,E)$ be a Hamiltonian DAG.

Since $G$ is Hamiltonian, there exists a path $p = [v_1, \ldots, v_n]$ where $\{v_1,\ldots, v_n\}=V$. By definition, $p$ is a topological ordering.

Note that $v_i$ must come after each of $v_1, \ldots, v_{i-1}$ in every topological ordering, since we have path $[v_j, \cdots, v_i]$ for each $j$ smaller than $i$. Likewise, $v_{i+1}, \ldots, v_n$ must come after $v_i$ in every topological ordering since $v_i$ has a path to each of those.

Hence $v_i$ occurs in position $i$ in every topological ordering, i.e. every topological ordering is equal to $p$.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.