PathfindingD3Phase 3two-frontiersmeet-pointshortest-path

Bidirectional BFS

Two-ended BFS expansion to demonstrate frontier intersection optimization.

Easy Explanation

Bidirectional BFS searches from both start and goal at once, meeting in the middle to reduce explored area.

Renderer Mode

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

Arrays + Grid
Visualizer
O(V + E)Bidirectional BFS
Two-frontier grid playback showing forward and backward waves, intersection checks, and the final meeting path.

Grid

n/a

Visited

n/a

Meeting

n/a

Result

Searching

Safe mode: choose a tool to edit the grid.

Ready

Press Play or Step to start execution.

No Bidirectional BFS run available for visualization.
Legend: S/T start/target, # blocked, forward queue/visited (cyan/blue), backward queue/visited (pink/fuchsia), active side (amber/orange), meet (violet), final path (green).
Bidirectional BFS Implementation
Pseudocode + TypeScript
These examples show the core two-frontier idea independently from the playback engine so the meeting logic is easier to read.
pseudocode
function bidirectional_bfs(graph, start, target):
  if start == target:
    return [start]

  forward_queue <- [start]
  backward_queue <- [target]
  forward_parent[start] <- none
  backward_parent[target] <- none
  forward_seen <- { start }
  backward_seen <- { target }

  while forward_queue not empty and backward_queue not empty:
    active_direction <- choose_frontier(forward_queue, backward_queue)

    for each node in current_layer(active_direction):
      for neighbor in neighbors(node):
        if neighbor already seen by active_direction:
          continue

        record parent for neighbor in active_direction

        if neighbor seen by opposite_direction:
          return stitch_paths(forward_parent, backward_parent, neighbor)

        mark neighbor seen
        push neighbor into active frontier

  return no path
1.00xNo Run