Loading algorithms…
Loading visualizer…
Traverse graph nodes level-by-level using a FIFO queue. Guarantees the shortest path in unweighted graphs.
Breadth-First Search (BFS) is a fundamental graph traversal algorithm that explores nodes level by level starting from a designated source node.
level[current] + 1, set its parent pointer, mark it as visited, and push it into the queue.Because BFS visits all nodes at distance k before any node at distance k + 1, the first time BFS reaches a node, it is guaranteed to have found the shortest path (fewest edges) to that node in an unweighted graph.
💡 Dynamic Graph Extension: You can add new nodes and custom edges to the graph using the + Add Node tool in the visualizer above!
Click nodes to set source/target · Drag nodes to rearrange layout · Use "+ Add Node" to extend graph topology