Data Structure and Algorithms - Graphs DFS
Data Structure and Algorithms - Graphs DFS
Traversal
Depth First Search (DFS) algorithm traverses a graph in a
depthward motion and uses a stack to remember to get the next
vertex to start a search, when a dead end occurs in any iteration.
Ste
Traversal Description
p
We choose B, mark it
as visited and put
onto the stack.
Here B does not have
5
any unvisited
adjacent node. So,
we pop B from the
stack.