search
Class SearchGraph

java.lang.Object
  |
  +--search.SearchGraph

class SearchGraph
extends java.lang.Object

The SearchGraph class is a container for a set of SearchNodes. A SearchGraph is used by the five basic search algorithms: depth-first, breadth-first, iterated, best-first, and genetic.


Field Summary
(package private)  java.util.Hashtable graph
           
(package private)  java.lang.String name
           
 
Constructor Summary
SearchGraph(java.lang.String name)
          Creates a SearchGraph with the given name.
 
Method Summary
 SearchNode bestFirstSearch(SearchNode initialNode, java.lang.Object goalState)
          Does a best-first search on graph, starting the the given initial node and continuing until the goal state is reached.
 SearchNode breadthFirstSearch(SearchNode initialNode, java.lang.Object goalState)
          Method breadthFirstSearch
 SearchNode depthFirstSearch(SearchNode initialNode, java.lang.Object goalState)
          Does a depth-first search on graph, starting the the given initial node and continuing until the goal state is reached.
 SearchNode depthLimitedSearch(SearchNode initialNode, java.lang.Object goalState, int maxDepth)
          Does a depth-first search on graph, starting the the given initial node and continuing until the goal state is reached or the given depth is reached.
 java.util.Hashtable getGraph()
          Returns the search graph.
 SearchNode getNode(java.lang.String nodeName)
          Returns the search node associated with the given node name.
 SearchNode iterDeepSearch(SearchNode startNode, java.lang.Object goalState)
          Does a iterated deepening search on graph, a series of depth-first searches starting at the given initial node and continuing until the goal state is reached or an arbitrary depth is reached.
(package private)  void put(SearchNode node)
          Adds a node to the graph, using node label as key.
(package private)  void reset()
          Resets each search node in the graph.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

java.lang.String name

graph

java.util.Hashtable graph
Constructor Detail

SearchGraph

public SearchGraph(java.lang.String name)
Creates a SearchGraph with the given name.
Parameters:
name - the String that identifies the name of the graph
Method Detail

getGraph

public java.util.Hashtable getGraph()
Returns the search graph.
Returns:
the search graph

getNode

public SearchNode getNode(java.lang.String nodeName)
Returns the search node associated with the given node name.
Parameters:
nodeName - the String that names a node in the graph
Returns:
the search node associated with the given node name

reset

void reset()
Resets each search node in the graph.

put

void put(SearchNode node)
Adds a node to the graph, using node label as key.
Parameters:
node - the SearchNode to be added to the graph

depthFirstSearch

public SearchNode depthFirstSearch(SearchNode initialNode,
                                   java.lang.Object goalState)
Does a depth-first search on graph, starting the the given initial node and continuing until the goal state is reached.
Parameters:
initialNode - the SearchNode at which the search begins
goalState - the Object being searched for in the graph
Returns:
the SearchNode containing the goal is returned, if the goal state is found. Otherwise, null is returned.

breadthFirstSearch

public SearchNode breadthFirstSearch(SearchNode initialNode,
                                     java.lang.Object goalState)
Method breadthFirstSearch
Parameters:
initialNode - the SearchNode object
goalState - the Object object
Returns:
the SearchNode object

depthLimitedSearch

public SearchNode depthLimitedSearch(SearchNode initialNode,
                                     java.lang.Object goalState,
                                     int maxDepth)
Does a depth-first search on graph, starting the the given initial node and continuing until the goal state is reached or the given depth is reached.
Parameters:
initialNode - the SearchNode at which the search begins
goalState - the Object being searched for in the graph
maxDepth - the maximum depth to be searched
Returns:
the SearchNode containing the goal is returned, if the goal state is found. Otherwise, null is returned.

iterDeepSearch

public SearchNode iterDeepSearch(SearchNode startNode,
                                 java.lang.Object goalState)
Does a iterated deepening search on graph, a series of depth-first searches starting at the given initial node and continuing until the goal state is reached or an arbitrary depth is reached.
Parameters:
initialNode - the SearchNode at which the search begins
startNode - the SearchNode object
goalState - the Object being searched for in the graph
Returns:
the SearchNode containing the goal is returned, if the goal state is found. Otherwise, null is returned.

bestFirstSearch

public SearchNode bestFirstSearch(SearchNode initialNode,
                                  java.lang.Object goalState)
Does a best-first search on graph, starting the the given initial node and continuing until the goal state is reached. The "best" solution is determined by the cost associated with each SearchNode.
Parameters:
initialNode - the SearchNode at which the search begins
goalState - the Object being searched for in the graph
Returns:
the SearchNode containing the goal is returned, if the goal state is found. Otherwise, null is returned.