search
Class SearchNode

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

public class SearchNode
extends java.lang.Object

The SearchNode class contains the label or name and the state of a node in a SearchGraph.


Field Summary
static int BACK
           
protected  float cost
           
protected  int depth
           
protected  boolean expanded
           
static int FRONT
           
static int INSERT
           
protected  java.lang.String label
           
protected  java.util.Vector links
           
protected  java.lang.Object oper
           
protected  java.lang.Object state
           
protected  boolean tested
           
 
Constructor Summary
(package private) SearchNode(java.lang.String label, java.lang.Object state)
          Creates a SearchNode with a given name and state.
 
Method Summary
 void addLink(SearchNode node)
          Adds a link to another SearchNode in the graph.
 void addLinks(SearchNode[] nodes)
          Adds links to a set of SearchNodes in the graph.
 void expand(java.util.Vector queue, int position)
          Expands the node and add to a queue at specified position.
 java.lang.Object getState()
          Gets the Object that represents the state of the node.
 boolean isExpanded()
          Indicates whether the node has been expanded or not.
 boolean isTested()
          Indicates whether the node has been tested or not.
 boolean leaf()
          Determines if the SearchNode is a leaf node in the graph.
 void reset()
          Initializes the node for another search.
 void setDepth(int depth)
          Sets the depth of this SearchNode in the graph.
static void setDisplay(javax.swing.JTextArea textArea)
          Sets the trace text area.
 void setExpanded()
          Sets the SearchNode flag that indicates the node has been expanded.
 void setExpanded(boolean state)
          Sets the SearchNode flag that indicates whether the node has been expanded.
 void setOperator(java.lang.Object oper)
          Sets the operator of the SearchNode.
 void setTested()
          Sets the SearchNode flag that indicates that the node has been tested.
 void setTested(boolean state)
          Sets the SearchNode flag that indicates whether the node has been tested.
 void trace()
          Writes a trace statement, using indentation to indicate depth within the graph.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

label

protected java.lang.String label

state

protected java.lang.Object state

oper

protected java.lang.Object oper

links

protected java.util.Vector links

depth

protected int depth

expanded

protected boolean expanded

tested

protected boolean tested

cost

protected float cost

FRONT

public static final int FRONT

BACK

public static final int BACK

INSERT

public static final int INSERT
Constructor Detail

SearchNode

SearchNode(java.lang.String label,
           java.lang.Object state)
Creates a SearchNode with a given name and state.
Parameters:
label - the String that represents the node name
state - the Object the represents the state of the node
Method Detail

addLink

public void addLink(SearchNode node)
Adds a link to another SearchNode in the graph.
Parameters:
node - the SearchNode to be linked to

addLinks

public void addLinks(SearchNode[] nodes)
Adds links to a set of SearchNodes in the graph.
Parameters:
node - the SearchNode array that contains the nodes to be linked
nodes - the SearchNode[] object that contains

leaf

public boolean leaf()
Determines if the SearchNode is a leaf node in the graph.
Returns:
true if the node is a leaf. Otherwise, returns false.

setDepth

public void setDepth(int depth)
Sets the depth of this SearchNode in the graph.
Parameters:
depth - the depth of the node in the graph

setOperator

public void setOperator(java.lang.Object oper)
Sets the operator of the SearchNode.
Parameters:
oper - the Object that contains the definition of the operation that created the state of the node

setExpanded

public void setExpanded()
Sets the SearchNode flag that indicates the node has been expanded.

setExpanded

public void setExpanded(boolean state)
Sets the SearchNode flag that indicates whether the node has been expanded.
Parameters:
state - the boolean that indicates whether the node has been expanded or not

isExpanded

public boolean isExpanded()
Indicates whether the node has been expanded or not.
Returns:
true if the node has been expanded. Otherwise, returns false.

setTested

public void setTested()
Sets the SearchNode flag that indicates that the node has been tested.

setTested

public void setTested(boolean state)
Sets the SearchNode flag that indicates whether the node has been tested.
Parameters:
state - the boolean that indicates whether the node has been tested or not

isTested

public boolean isTested()
Indicates whether the node has been tested or not.
Returns:
true if the node has been tested. Otherwise, returns false.

setDisplay

public static void setDisplay(javax.swing.JTextArea textArea)
Sets the trace text area.
Parameters:
the - JTextArea to be displayed in the trace text area
textArea - the JTextArea object that contains

getState

public java.lang.Object getState()
Gets the Object that represents the state of the node.
Returns:
the Object the represents state of the node

reset

public void reset()
Initializes the node for another search.

trace

public void trace()
Writes a trace statement, using indentation to indicate depth within the graph.

expand

public void expand(java.util.Vector queue,
                   int position)
Expands the node and add to a queue at specified position.
Parameters:
queue - the Vector to which the node is added
position - where in the queue the node should be added; 0=front, 1=back, 2=base position on node cost