is an algorithm for traversing or searching tree or graph data structures. It starts at the tree root (or some arbitrary node of a graph, sometimes referred to as a ‘search key’) and explores the neighbor nodes first, before moving to the next level neighbors.
Input: A graph G and a starting vertex v of G
Output: All vertices reachable from v labeled as explored.
A non-recursive implementation of breadth-first search: