Traverse the graph starting from node A using DFS.
DFS: Go as deep as possible along each branch before backtracking, using a stack.