Personal website Rudolf Adamkovič

Home / Computer science / Generic search


Algorithm

The steps of generic search on \(G = (V, E)\), given

  • a starting vertex \(v_1 \in V\) and
  • a goal predicate \(g : (v_1, \ldots, v_k) \to \mathbb{B}\)

are:

  1. start with the frontier \(F = \{(v_1)\}\) and seen vertices \(S = \{v_1\}\)
  2. if \(|F| = 0\), return empty-handed (\(\bot\))
  3. remove some path \(p = (v_1, \ldots, v_k)\) from \(F\)
  4. when the goal predicate \(g(p)\) is true 1, return \(p\) as the solution
  5. select \(N = \{(v_1, v_2, \ldots, v_k, v^*) : v^* \notin S \land (v_k, v^*) \in E\}\)
  6. for each \(n \in N\), insert \(n\) to \(F\)
  7. for each \((v_1, v_2, \ldots, v_k, v^*) \in N\), insert \(v^*\) to \(S\)
  8. go to step 2.

Footnotes:

1

For all \(p\), \(g(p)\) is tested after adding \(p\) to \(F\) to

  • enable informed variants take into account cost and
  • avoid evaluating computationally expensive \(g\) unnecessarily.

© 2025 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and secret alien technologies of yesteryear.