Class Subgraph

java.lang.Object
edu.uky.ai.planning.pg.Subgraph
All Implemented Interfaces:
Iterable<NodeInstance>

public class Subgraph extends Object implements 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 Details

    • first

      public NodeInstance first
      The first node (and the level at which it appears) in the subgraph
    • rest

      public Subgraph rest
      The rest of the subgraph
  • Constructor Details

    • Subgraph

      public Subgraph()
      Constructs an empty subgraph, containing no nodes.
  • Method Details

    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • iterator

      public Iterator<NodeInstance> iterator()
      Specified by:
      iterator in interface Iterable<NodeInstance>
    • size

      public int size()
      Indicates how many nodes this subgraph contains.
      Returns:
      the number of nodes
    • contains

      public boolean contains(Node node, int level)
      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 for
      level - the level of the node being search for
      Returns:
      true if this subgraph contains this node at this level, false otherwise
    • add

      public Subgraph add(Node node, int level)
      Returns a new subgraph which contains a given node at a given level.
      Parameters:
      node - the node to add to the subgraph
      level - the level at which to add the node to the subgraph
      Returns:
      a new subgraph containing that node at that level
    • add

      public Subgraph add(NodeInstance instance)
      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

      public Subgraph remove(Node node, int level)
      Returns a new subgraph which does not contain a given node at a given level.
      Parameters:
      node - the node to be removed from the subgraph
      level - 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

      public Subgraph remove(NodeInstance instance)
      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

      public Plan getPlan()
      Converts the step nodes in this subgraph into a plan.
      Returns:
      the plan this subgraph represents