Class State

java.lang.Object
  extended by State

public class State
extends java.lang.Object

This class represents a single state vertex in a graph of states.

Version:
V1.0, 3/2012
Author:
Nathan Sprague

Constructor Summary
State(java.lang.String name)
          Construct a vertex.
 
Method Summary
 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()
          Convert the vertex to a string (just return the name.)
 
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()
Convert the vertex to a string (just return the name.)

Overrides:
toString in class java.lang.Object
Returns:
The name of the vertex.