PathfindingD1Phase 1unweightedtraversalqueue

Breadth-First Search

Layer-by-layer traversal that guarantees shortest paths in unweighted graphs.

Easy Explanation

BFS explores neighbors level by level, so the first time it reaches a target is the shortest unweighted path.

Renderer Mode

`Simple` uses abstract, short-form-friendly visuals. `Advanced` keeps the current detailed view.

Arrays + Grid
Visualizer
O(V + E)BFS
Deterministic frontier expansion on a grid with visit, queue, and neighbor-inspection playback.

Grid

n/a

Visited

0

Distance

n/a

Result

Searching

Safe mode: choose a tool to edit the grid.

Ready

Press Play or Step to start execution.

No BFS run available for visualization.
Legend: S/T start/target, # blocked, queued (cyan), visited (blue), current (amber), path (green).
Breadth-First Search Implementation
Pseudocode + TypeScript
Reference implementation examples are intentionally abstracted from the playback engine so learners can map concepts to code.
pseudocode
function bfs(graph, start, target):
  queue <- [start]
  visited <- { start }
  parent[start] <- none

  while queue is not empty:
    node <- pop_front(queue)

    if node == target:
      return reconstruct_path(parent, target)

    for neighbor in neighbors(node):
      if neighbor not in visited:
        visited.add(neighbor)
        parent[neighbor] <- node
        push_back(queue, neighbor)

  return no path
1.00xNo Run