Consider the following sequence of nodes for the undirected graph given below.
- a b e f d g c
- a b e f c g d
- a d g e b c f
- a d b c g e f
A Depth First Search (DFS) is started at node a. The nodes are listed in the order they are first visited. Which all of the above is (are) possible output(s)?
- 1 and 3 only
- 2 and 3 only
- 2, 3 and 4 only
- 1, 2 and 3 only
My attempt :
- After f is visited, c or g should be visited next.
- Visited depth
- Visited depth
- After c is visited, e or f should be visited next.
Can you explain in more formal way, please?

$1$ is impossible because if the stack consists of $(a,b,e,f)$ (with $f$ at the top), then the next node traversed must be $c$ or $g$, since those are adjacent to $f$ and have not been traversed yet.
$2$ is possible; if the stack consists of $(a,b,e,f,c)$ then we must pop $c$ and then $f$, and can then push $g$ and $d$.
$3$ is possible, as it is a path in the graph.
$4$ is impossible for the same reason as $1$.