Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
All algorithms

Bidirectional BFS

Also known as Bidirectional breadth-first search, bidirectional breadth-first search, bibfs-uc

search heuristic-searchminiplan

Bidirectional BFS finds a path with the fewest edges. It runs breadth-first search forwards from the start and backwards from the goals, one whole layer at a time, and stops when a new layer meets the other side. bidirectional_bfs always grows the smaller frontier and returns the shortest meet of that layer. Edge costs do not guide the search; the reported cost is the sum of the costs along the returned path. On graphs where each state has many successors, it expands far fewer states than one-sided breadth-first search, but it needs the predecessors of each state.

Pseudocode

algorithm Bidirectional BFS(s₀, GOALS)input: start s₀, a set of goal states GOALS, successors and predecessorsoutput: a path with the fewest edges, or failuredF[s₀] ← 0                                   ▷ edges from the startdB[t] ← 0 for each t in GOALS                ▷ edges to a goalLF ← {s₀}LB ← GOALSwhile LF ≠ ∅ and LB ≠ ∅ doif |LF| ≤ |LB| thenLF, MEETS ← expand-layer(LF, successors, dF, dB)elseLB, MEETS ← expand-layer(LB, predecessors, dB, dF)if MEETS ≠ ∅ thenm ← the state of MEETS with the smallest dF[m] + dB[m]return join(path from s₀ to m, path from m to a goal)return failurefunction expand-layer(L, next, d, d-other)NEW ← ∅MEETS ← ∅for each s in L dofor each s′ in next(s) doif s′ is new on this side thend[s′] ← d[s] + 1parent[s′] ← sNEW ← NEW ∪ {s′}if s′ was reached by the other side thenMEETS ← MEETS ∪ {s′}return NEW, MEETS

In the crates

Lineage

Comes from

builds on Breadth-first search

Led to

Nothing on this site.