Package edu.uky.ai.planning.pg
Class Subgraph
java.lang.Object
edu.uky.ai.planning.pg.Subgraph
- All Implemented Interfaces:
Iterable<NodeInstance>
Represents a specific subset of nodes in a plan graph. Subsets are
generally used when searching a plan graph for a solution plan. This is an
immutable data structure, so its
add
and
remove
methods do not modify this object, but
instead return a new subgraph that reflects the changes. Note that
this is a set, meaning that it will not contain duplicates.- Author:
- Stephen G. Ware
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe first node (and the level at which it appears) in the subgraphThe rest of the subgraph -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionadd
(NodeInstance instance) Returns a new subgraph which contains a given node at a given level.Returns a new subgraph which contains a given node at a given level.boolean
Tests whether this subgraph contains a given node at the given level.boolean
getPlan()
Converts the step nodes in this subgraph into a plan.int
hashCode()
iterator()
remove
(NodeInstance instance) Returns a new subgraph which does not contain a given node at a given level.Returns a new subgraph which does not contain a given node at a given level.int
size()
Indicates how many nodes this subgraph contains.toString()
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
first
The first node (and the level at which it appears) in the subgraph -
rest
The rest of the subgraph
-
-
Constructor Details
-
Subgraph
public Subgraph()Constructs an empty subgraph, containing no nodes.
-
-
Method Details
-
equals
-
hashCode
public int hashCode() -
toString
-
iterator
- Specified by:
iterator
in interfaceIterable<NodeInstance>
-
size
public int size()Indicates how many nodes this subgraph contains.- Returns:
- the number of nodes
-
contains
Tests whether this subgraph contains a given node at the given level. Note that both node and level are checked, so if this method is called for literal A at level 2, and this subgraph contains A (but not at level 2), this method will return false.- Parameters:
node
- the node to search forlevel
- the level of the node being search for- Returns:
- true if this subgraph contains this node at this level, false otherwise
-
add
Returns a new subgraph which contains a given node at a given level.- Parameters:
node
- the node to add to the subgraphlevel
- the level at which to add the node to the subgraph- Returns:
- a new subgraph containing that node at that level
-
add
Returns a new subgraph which contains a given node at a given level.- Parameters:
instance
- specifies the node to add the level at which to add it- Returns:
- a new subgraph containing that node at that level
-
remove
Returns a new subgraph which does not contain a given node at a given level.- Parameters:
node
- the node to be removed from the subgraphlevel
- the level at which to remove the node from the subgraph- Returns:
- a new subgraph that does not contain that node at that level
-
remove
Returns a new subgraph which does not contain a given node at a given level.- Parameters:
instance
- specifies the node to remove the level at which to remove it- Returns:
- a new subgraph that does not contain that node at that level
-
getPlan
Converts the step nodes in this subgraph into a plan.- Returns:
- the plan this subgraph represents
-