Skip to content

BFS [mp]

Micro pattern

Description

Explore states level by level so the first visit reaches a state through the fewest unweighted edges.

Problems

Graph BFS

Mark states on discovery to avoid repeated insertion into the queue.

Tree levels

Freeze the current queue length to process one tree level at a time.

Multi-source BFS

Seed the queue with all sources to expand their waves together.

Bidirectional BFS

Expand frontiers from both endpoints to reduce the explored state space.