Algorithm
Breadth-First Search
Breadth-First Search (BFS) is a fundamental graph traversal algorithm that systematically explores a graph by visiting all neighbors at the current depth level before moving to nodes at the next depth. Starting from a source node, BFS uses a queue data structure to maintain the order of exploration, ensuring that nodes are visited in order of their distance from the source. This level-by-level exploration creates a breadth-first tree that reveals the shortest path (in terms of number of edges) from the source to any reachable node. BFS is essential in numerous applications, including finding shortest paths in unweighted graphs, testing bipartiteness, computing network flow, and solving puzzles like the 15-puzzle or Rubik's cube. Its O(V+E) time complexity makes it efficient for both dense and sparse graphs, though it requires O(V) space to store the queue and visited nodes. Unlike Depth-First Search, BFS guarantees finding the shortest path in unweighted graphs and tends to be more useful for finding nodes close to the starting point.
Visualization
No graph data available