breadth_first_traversal

  • Unlike trees, graphs may contain cycles, so we may come to the same node again.
  • To avoid processing a node more than once, we use a boolean visited array.