org.eclipse.emf.henshin.statespace.util
Class StateSpaceSearch

java.lang.Object
  extended by org.eclipse.emf.henshin.statespace.util.StateSpaceSearch

public class StateSpaceSearch
extends Object

State space search implementation.


Constructor Summary
StateSpaceSearch()
           
 
Method Summary
 boolean depthFirst(List<State> states, boolean reverse)
          Perform a depth-first search.
 boolean depthFirst(State state, boolean reverse)
          Perform a depth-first search.
 boolean depthFirst(StateSpace stateSpace, boolean reverse)
          Perform a depth-first search, starting at the initial states.
static Path findPath(List<State> states)
          Find a Path for a given list of states.
static Path findPath(StateSpace stateSpace, List<String> trace)
          Find a Path for a given trace.
 State getCurrentState()
          Get the current state.
 Path getPath()
          Get the current path.
 Set<State> getVisitedStates()
          Get the set of visited states during the last search.
static List<State> removeUnreachableStates(StateSpace stateSpace)
          Remove all unreachable states from a state space.
 void reset()
          Reset this state space search.
protected  boolean shouldStop(State current, Path path)
          Visit a state and check whether the search should be stopped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateSpaceSearch

public StateSpaceSearch()
Method Detail

shouldStop

protected boolean shouldStop(State current,
                             Path path)
Visit a state and check whether the search should be stopped.

Parameters:
current - Current state.
path - Path from one of the start states to the current state.
Returns:
true if the search should stop.

depthFirst

public boolean depthFirst(List<State> states,
                          boolean reverse)
Perform a depth-first search.

Parameters:
states - Start states.
reverse - Flag indicating if the traversal should be in reverse direction.

depthFirst

public boolean depthFirst(StateSpace stateSpace,
                          boolean reverse)
Perform a depth-first search, starting at the initial states.

Parameters:
stateSpace - State space.

depthFirst

public boolean depthFirst(State state,
                          boolean reverse)
Perform a depth-first search.

Parameters:
state - Start state.

reset

public void reset()
Reset this state space search. This clears the set of visited states.


removeUnreachableStates

public static List<State> removeUnreachableStates(StateSpace stateSpace)
Remove all unreachable states from a state space.

Parameters:
stateSpace - State space.

findPath

public static Path findPath(StateSpace stateSpace,
                            List<String> trace)
Find a Path for a given trace.

Parameters:
stateSpace - State space.
trace - Trace (list of transition labels).
Returns:
A path if found, null otherwise.

findPath

public static Path findPath(List<State> states)
Find a Path for a given list of states.

Returns:
A path if found, null otherwise.

getVisitedStates

public Set<State> getVisitedStates()
Get the set of visited states during the last search.

Returns:
Visited states.

getCurrentState

public State getCurrentState()
Get the current state.

Returns:
State.

getPath

public Path getPath()
Get the current path.

Returns:
Current path.