aima.search.framework
Class GraphSearch
java.lang.Object
aima.search.framework.NodeExpander
aima.search.framework.QueueSearch
aima.search.framework.GraphSearch
public class GraphSearch
- extends QueueSearch
Artificial Intelligence A Modern Approach (2nd Edition): Figure 3.19, page
83.
function GRAPH-SEARCH(problem, fringe) returns a solution, or failure
closed <- an empty set
fringe <- INSERT(MAKE-NODE(INITIAL-STATE[problem]), fringe)
loop do
if EMPTY?(fringe) then return failure
node <- REMOVE-FIRST(fringe)
if (GOAL-TEST[problem](STATE[node]) then return SOLUTION(node)
if STATE[node] is not in closed then
add STATE[node] to closed
fringe <- INSERT-ALL(EXPAND(node, problem), fringe)
Figure 3.19 The general graph-search algorithm, The set closed can be
implemented with a hash table to allow efficient checking for repeated
states. This algorithm assumes that the first path to a state s is the
cheapest (see text).
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GraphSearch
public GraphSearch()
search
public java.util.List<java.lang.String> search(Problem problem,
NodeStore fringe)
- Overrides:
search
in class QueueSearch
addExpandedNodesToFringe
public void addExpandedNodesToFringe(NodeStore fringe,
Node node,
Problem problem)
- Specified by:
addExpandedNodesToFringe
in class QueueSearch