Algorithm. DFS (version 2, with parent tree) [00M9]
What if we want to find an explicit path from s to t? As it stands, we can't: we need more information. In particular, we need to know how we got to each vertex. We can add a parent dictionary which stores the parent of each visited vertex. Every time we visit a vertex, we record its parent, i.e. the neighbor we "came from".
Note that the resulting \mathit {parent} dictionary records a tree, representing the paths we took while exploring the graph. However, instead of the each node recording its children, each node simply records its parent. So we can easily move up the tree, but not down.
That's OK though—moving up is all we need! In order to find a path from s to t (in reverse order) we can look up \mathit {parent}[t], \mathit {parent}[\mathit {parent}[t]], and so on.