##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Consider a graph that is already nice, and run a DFS that discovers vertices in the order (with some suitable adjacency-list order).
Look at the DFS tree and focus on vertex . Suppose its children in the DFS tree are in the order they are first visited.
A crucial property is that each child subtree forms a contiguous interval in the DFS order: the vertices in the subtree of are exactly for some , and these intervals partition .
Two key facts follow:
(No edges between different child intervals)
If and with , then there is no edge in a nice graph.
Reason: while DFS is exploring one child interval, all vertices of other intervals are still unvisited, so any such edge would let DFS jump to another interval and break the discovery order.
(The parent connects to the start of each interval)
For every child interval , vertex must be connected to its first vertex by a DFS-tree edge, i.e. must exist (and be kept).
Otherwise DFS could not enter that interval starting at .