Class Node

java.lang.Object
  extended byNode

public class Node
extends java.lang.Object

This is the class for representing a single search node. Such a node consists of a State representing the actual configuration of the puzzle, as well as the depth of the search node from the initial state, and the parent node of the current node in the search tree, i.e., the node from which this node was expanded. Thus, the path from the initial node to this node can be computed by tracing backward using the parent links. (The parent of the initial node is set to null.) The total distance from the initial node is equal to the depth of this node.


Constructor Summary
Node(State state, int depth, Node parent)
          The main constructor for constructing a search node.
 
Method Summary
 Node[] expand()
          Expands this node, in other words, computes all of the nodes immediately reachable from this node according to the rules of the puzzle and returns them as an array of nodes.
 int getDepth()
          Returns the depth of this node.
 Node getParent()
          Returns this node's parent node.
 State getState()
          Returns the state associated with this node.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Node

public Node(State state,
            int depth,
            Node parent)
The main constructor for constructing a search node. You probably will never need to use this constructor directly, since ordinarily, new nodes will be gotten from the expand method.

Parameters:
state - the state that resides at this node
depth - the search depth of this node
parent - the parent of this node
Method Detail

getState

public State getState()
Returns the state associated with this node.


getParent

public Node getParent()
Returns this node's parent node.


getDepth

public int getDepth()
Returns the depth of this node.


expand

public Node[] expand()
Expands this node, in other words, computes all of the nodes immediately reachable from this node according to the rules of the puzzle and returns them as an array of nodes.