The Depth First Search (DFS) algorithm traverses a graph in a depth-to-depth motion and uses a stack to note that when a dead end occurs in any iteration, the next vertex will start a search.

As in the above example, the DFS algorithm traverses first, then to F and finally to C, from S to A to D to G to E to B. The following laws are hired.
Rule 1 − Visit the unvisited vertex next to it. Mark it as having been visited. Only show it. Move it into the stack.
Rule 2 − Pop up a vertex from the stack if no neighbouring vertex is located. (All the vertices that do not have neighbouring vertices will pop up from the stack.)
Rule 3 − Repeat Rule 1 and Rule 2 until the stack is empty.

As C has no adjacent node that is unvisited, we keep popping up the stack until we find a node that has an adjacent node that is unvisited. There’s none in this situation and we keep showing up until the stack is empty.