Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
All algorithms

Depth-limited DFS

Also known as Depth-limited search

search heuristic-search

Depth-limited DFS is depth-first search that never goes deeper than limit edges. It keeps only the current path in memory and skips a successor that is already on that path, so it needs no closed set. It finds some path of at most limit edges, not a short or cheap one. If it finds no goal, it says the problem is unsolvable only when the limit cut nothing off; otherwise it reports a cutoff, because a goal can lie deeper. Use it when memory is tight and you know a bound on the path length.

Pseudocode

algorithm Depth-limited DFS(s₀, goal, limit)input: start state s₀, goal test goal, depth limit limitoutput: a path of at most limit edges, a cutoff, or failureif goal(s₀) thenreturn ⟨s₀⟩PATH ← ⟨s₀⟩                                  ▷ the only states kept in memorycut ← falsewhile PATH ≠ ⟨⟩ dos ← last(PATH)s′ ← next untried successor of s, or nilif s′ = nil thenpop(PATH)                                ▷ backtrackelse if s′ ∈ PATH thenskip                                     ▷ no cycles on the current pathelse if |PATH| > limit then                ▷ s′ would lie |PATH| edges deepcut ← true                               ▷ a goal may lie deeperelse if goal(s′) thenreturn PATH followed by s′elsepush(PATH, s′)if cut thenreturn cutoffreturn failure

In the crates

Lineage

Comes from

builds on DFS

Led to

IDDFS builds on it