(B) [pre(v), post(v)] ⊆ [pre(u), post(u)]: impossible as post(v) > post(u).
(C) [pre(u), post(u)] ⊆ [pre(v), post(v)]. But then DFS visited v, and then visited u.
Namely there is a path in G from v to u. But then if (u, v) ∈ E(G) then there would
be a cycle in G, and it would not be a DAG. Contradiction.
(D) No other possibility - since “lifetime” intervals of DFS are either disjoint or contained
in each other.
2.1.1.2 Example
..
1
.
2
.
3
.
4
2.1.1.3 Back edge and Cycles
Proposition 2.1.8 G has a cycle iff there is a back-edge in DFS(G).
Proof : If: (u, v) is a back edge implies there is a cycle C consisting of the path from v to u
in DFS search tree and the edge (u, v).
Only if: Suppose there is a cycle C = v
1
→ v
2
→ . . . → v
k
→ v
1
.
Let v
i
be first node in C visited in DFS.
All other nodes in C are descendants of v
i
since they are reachable from v
i
.
Therefore, (v
i−1
, v
i
) (or (v
k
, v
1
) if i = 1) is a back edge.
2.1.1.4 DAGs and Partial Orders
Definition 2.1.9 A partially ordered set is a set S along with a binary relation such
that is
1. reflexive (a a for all a ∈ V ),
2. anti-symmetric (a b and a 6= b implies b 6 a), and
3. transitive (a b and b c implies a c).
Example: For numbers in the plane define (x, y) (x
0
, y
0
) iff x ≤ x
0
and y ≤ y
0
.
Observation: A finite partially ordered set is equivalent to a DAG. (No equal elements.)
Observation: A topological sort of a DAG corresponds to a complete (or total) ordering
of the underlying partial order.
5