How to read a search problem
Every algorithm on this site searches a problem built from the same handful of pieces. Learn these once, and every page β and the visualizer β makes sense.
The vocabulary
A situation the problem can be in β for a trip, which airport you're at. All possible states together make up the state space.
A state as it appears in the search, drawn as a circle. As the rule goes: βnodes are states; actions are the arrows between them.β
A move that takes you from one state to another β a flight from one airport to the next. Each action has a cost.
The initial state you begin from and the goal you're trying to reach. Checking βare we there yet?β is the goal test.
A sequence of actions from the start to a node. A path that reaches the goal is a solution; its cost is the sum of the action costs.
To open up a node and generate every state it can reach next (its neighbours / successors).
OPEN (the frontier) = discovered but not yet expanded. CLOSED = already expanded. The order of CLOSED is the traversal.
The cost so far β the real cost of the path from the start to node n.
The heuristic β an estimate of the cost still to go from n to the goal. A smart guess, never exact.
A*'s evaluation function: cost already paid plus the estimated cost to go = the estimated total for a path through n. A* always expands the node with the smallest f.
π‘ g, h and f matter most for informed search (Greedy uses h; A* uses f = g + h). Uninformed search (BFS, DFS, UCSβ¦) ignores h and just explores by rule.
Now you can read any of them
Pick an algorithm to see these pieces in action β with theory, a step-by-step gallery and a live run.