com.x8ing.lsm4j.state
Class StaticGraph

java.lang.Object
  extended by com.x8ing.lsm4j.state.StaticGraph
Direct Known Subclasses:
ProcessableGraph

public class StaticGraph
extends java.lang.Object

Stores the structure of a graph. It must be possible to have several tansitions between two nodes.

We need two ways to fast get a transition.

1. get all transitions starting from a node A.
2. get all transition between node A and node B
We make a memory/speed tradeoff and use two hashmaps:
1. internode hashmap
2. outgoing node hashmap

Author:
Patrick Heusser

Nested Class Summary
protected static class StaticGraph.StateIterator
          TODO implement stateiterator and transition iterator!!!
protected static class StaticGraph.TransitionList
          A list of transitions.
 
Constructor Summary
StaticGraph()
           
 
Method Summary
 void addTransition(StaticTransition transition)
           
 void addValidTransition(StaticState currentState, StaticState nextState)
           
 void addValidTransition(StaticTransition transition)
           
 int getStateCount()
           
protected  StaticState getStateWithID(int stateUID)
           
 java.util.List getTransitionListForState(int stateUID)
          Get a list of transitions that leave a certain state.
 java.util.List getTransitionsBetweenStates(int currentStateUID, int nextStateUID)
          Get a list of transitions that are between two states.
 int getTransitionsCount()
           
 boolean isValidTransition(StaticState currentState, StaticState nextState)
           
 boolean isValidTransition(StaticTransition transition)
           
 java.lang.String printGraph()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StaticGraph

public StaticGraph()
Method Detail

getStateWithID

protected StaticState getStateWithID(int stateUID)
Returns:
null if not found

addTransition

public void addTransition(StaticTransition transition)

getTransitionListForState

public java.util.List getTransitionListForState(int stateUID)
Get a list of transitions that leave a certain state. If nothing is found, an empty list is returned.

Parameters:
stateUID -
Returns:
List with elements of type: StaticTransition

getTransitionsBetweenStates

public java.util.List getTransitionsBetweenStates(int currentStateUID,
                                                  int nextStateUID)
Get a list of transitions that are between two states. If nothing is found, an empty list is returned.

Parameters:
currentStateUID -
nextStateUID -
Returns:
List with elements of type: StaticTransition

printGraph

public java.lang.String printGraph()

getTransitionsCount

public int getTransitionsCount()
Returns:
the count of transitions in the graph.

getStateCount

public int getStateCount()
Returns:
the count of states in the graph.

addValidTransition

public void addValidTransition(StaticTransition transition)

addValidTransition

public void addValidTransition(StaticState currentState,
                               StaticState nextState)

isValidTransition

public boolean isValidTransition(StaticTransition transition)

isValidTransition

public boolean isValidTransition(StaticState currentState,
                                 StaticState nextState)

toString

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


by Patrick Heusser