Class SearchNode

  • All Implemented Interfaces:
    QueueElement
    Direct Known Subclasses:
    AStarNode

    public class SearchNode
    extends java.lang.Object
    implements QueueElement
    Created by IntelliJ IDEA. User: pereira Date: Jun 20, 2005 Time: 4:46:56 PM Search tree node. A search tree node pertains to some search graph state. Multiple nodes may refer to the same state, representing different ways of reaching the state. Search nodes have a priority, which determines when they will be expanded, and cost of reaching the node from the start of the search.
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      class  SearchNode.NextNodeIterator
      This iterator generates search nodes that refer to the states reachable from the state pertaining to a this search node.
    • Constructor Summary

      Constructors 
      Constructor Description
      SearchNode​(SearchState state, SearchNode parent, double cost)
      Create a search node with given state, parent, and cost.
    • Constructor Detail

      • SearchNode

        public SearchNode​(SearchState state,
                          SearchNode parent,
                          double cost)
        Create a search node with given state, parent, and cost.
        Parameters:
        state - the state
        parent - the parent
        cost - the cost
    • Method Detail

      • getPriority

        public double getPriority()
        Description copied from interface: QueueElement
        Get this element's priority.
        Specified by:
        getPriority in interface QueueElement
        Returns:
        the priority
      • setPriority

        public void setPriority​(double priority)
        Description copied from interface: QueueElement
        Set the priority of this element.
        Specified by:
        setPriority in interface QueueElement
        Parameters:
        priority - the element's new priority
      • getPosition

        public int getPosition()
        Description copied from interface: QueueElement
        Get the queue position of this element. If the element is not in a queue, the returned value is meaningless.
        Specified by:
        getPosition in interface QueueElement
        Returns:
        the current position
      • setPosition

        public void setPosition​(int position)
        Description copied from interface: QueueElement
        Set the current queue position for this element. This should only be called by a queue implementation.
        Specified by:
        setPosition in interface QueueElement
        Parameters:
        position - the new position for the element
      • getParent

        public SearchNode getParent()
        The node that generated this node.
        Returns:
        the parent
      • getCost

        public double getCost()
        Get the cost for this node.
        Returns:
        the cost
      • getState

        public SearchState getState()
        The state for this search node.
        Returns:
        the state
      • isFinal

        public boolean isFinal()
        Is the node's state final?
        Returns:
        whether this state's node is final
      • getNextNodes

        public SearchNode.NextNodeIterator getNextNodes()
        Get an iterator over the new search nodes reachable from this node by state transitions.
        Returns:
        the iterator
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object