function GRAPHPLAN(problem) returns solution or failure
graph ← INITIAL-PLANNING-GRAPH(problem)
goals ← CONJUNCTS(problem.GOAL)
nogoods ← an empty hash table
for tl = 0 to ∞ do
if goals all non-mutex in St of graph then
solution ← EXTRACT-SOLUTION(graph, goals, NUMLEVELS(graph), nogoods)
if solution ≠ failure then return solution
if graph and nogoods have both leveled off then return failure
graph ← EXPAND-GRAPH(graph, problem)
Figure ?? The GRAPHPLAN algorithm. GRAPHPLAN calls EXPAND-GRAPH to add a level until either a solution is found by EXTRACT-SOLUTION, or no solution is possible.