Class State


  • public class State
    extends java.lang.Object
    This class represents a single state vertex in a graph of states.
    Version:
    V2.0, 4/2021
    Author:
    Nathan Sprague
    • Constructor Summary

      Constructors 
      Constructor Description
      State​(java.lang.String name)
      Construct a vertex.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNeighbor​(State neighbor)
      Add a neighbor to the adjacency list for this vertex.
      java.lang.String getName()
      Return the name associated with this vertex.
      java.util.ArrayList<State> getNeighbors()
      Return the adjacency list for this vertex.
      boolean isVisited()
      Check to see if the current vertex has been visited.
      void setVisited​(boolean visited)
      Set or un-set the visited flag for this vertex.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • State

        public State​(java.lang.String name)
        Construct a vertex. (The name should be unique!)
        Parameters:
        name - The name associated with this vertex.
    • Method Detail

      • addNeighbor

        public void addNeighbor​(State neighbor)
        Add a neighbor to the adjacency list for this vertex.
        Parameters:
        neighbor - A vertex to add to the adjacency list.
      • getNeighbors

        public java.util.ArrayList<State> getNeighbors()
        Return the adjacency list for this vertex.
        Returns:
        The list of adjacent vertices.
      • isVisited

        public boolean isVisited()
        Check to see if the current vertex has been visited. This value is not set automatically -- it must be set by by calling setVisited. (This could be useful in conducting recursive graph traversals.)
        Returns:
        True if the vertex has been visited, false otherwise.
      • setVisited

        public void setVisited​(boolean visited)
        Set or un-set the visited flag for this vertex.
        Parameters:
        visited - New value for the visited flag.
      • getName

        public java.lang.String getName()
        Return the name associated with this vertex.
        Returns:
        The name.
      • toString

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