Graph Traversal Algorithms


There are two ways to traverse in a graph in order to meet each node, which are:

  • Depth First Search (DFS): Uses a stack.
  • Breadth First Search (BFS): Uses a queue.

Depth First Search (DFS)

DFS is a graph traversal algorithm that explores as far as possible along each branch before backtracking. It can be implemented using recursion or an explicit stack.