@Test public void testGetRootState () { DirectedGraphImpl graph = new DirectedGraphImpl (GRAPH_NAME); State state1 = graph.addState ("state 1"); State state2 = graph.addState ("state 2"); State state3 = graph.addState ("state 3"); graph.addTransition(state1, state2); graph.addTransition(state2, state3); assertEquals (state1, graph.getRootState ()); }
public State getRootState () { Set<State> states = new HashSet<State> (); states.addAll (mStates.values ()); for (Set<Transition> set : mTransitions.values ()) { for (Transition transition : set) { states.remove (transition.mTarget); } } int nrOfRoots = states.size(); switch (nrOfRoots) { case 0: throw new ExecutionException ("no root state"); case 1: return states.iterator ().next (); default: throw new ExecutionException ("multiple root states"); } }
DirectedGraphImpl implements DirectedGraph { public State getRootState () { Set<State> states = new HashSet<State> (); states.addAll (mStates.values ()); for (Set<Transition> set : mTransitions.values ()) { for (Transition transition : set) { states.remove (transition.mTarget); } } int nrOfRoots = states.size(); switch (nrOfRoots) { case 0: throw new ExecutionException ("no root state"); case 1: return states.iterator ().next (); default: throw new ExecutionException ("multiple root states"); } } }
DirectedGraphImpl implements DirectedGraph { public State getRootState () { Set<State> states = new HashSet<State> (); states.addAll (mStates.values ()); for (Set<Transition> set : mTransitions.values ()) { for (Transition transition : set) { states.remove (transition.mTarget); } } int nrOfRoots = states.size(); switch (nrOfRoots) { case 0: throw new ExecutionException ("no root state"); case 1: return states.iterator ().next (); default: throw new ExecutionException ("multiple root states"); } } DirectedGraphImpl(String name); }
DirectedGraphImpl implements DirectedGraph { public State getRootState () { Set<State> states = new HashSet<State> (); states.addAll (mStates.values ()); for (Set<Transition> set : mTransitions.values ()) { for (Transition transition : set) { states.remove (transition.mTarget); } } int nrOfRoots = states.size(); switch (nrOfRoots) { case 0: throw new ExecutionException ("no root state"); case 1: return states.iterator ().next (); default: throw new ExecutionException ("multiple root states"); } } DirectedGraphImpl(String name); void read(String path, String fileName); String getName(); State addState(String name); State getState(String name); State getStateByLabel(String label); State getRootState(); State getBeginState(); Transition addTransition(String sourceName, String targetName); Transition addTransition(State source, State target); Transition getTransition(String sourceName, String targetName); Transition getTransition(State source, State target); Set<Transition> getTransitions(String sourceName); Set<Transition> getTransitions(State source); }
DirectedGraphImpl implements DirectedGraph { public State getRootState () { Set<State> states = new HashSet<State> (); states.addAll (mStates.values ()); for (Set<Transition> set : mTransitions.values ()) { for (Transition transition : set) { states.remove (transition.mTarget); } } int nrOfRoots = states.size(); switch (nrOfRoots) { case 0: throw new ExecutionException ("no root state"); case 1: return states.iterator ().next (); default: throw new ExecutionException ("multiple root states"); } } DirectedGraphImpl(String name); void read(String path, String fileName); String getName(); State addState(String name); State getState(String name); State getStateByLabel(String label); State getRootState(); State getBeginState(); Transition addTransition(String sourceName, String targetName); Transition addTransition(State source, State target); Transition getTransition(String sourceName, String targetName); Transition getTransition(State source, State target); Set<Transition> getTransitions(String sourceName); Set<Transition> getTransitions(State source);  }