src/main/java/de/dfki/lt/loot/fsa/FiniteAutomaton.java
public SubAutomaton addAutomaton(FiniteAutomaton<EdgeInfo> aut) {

    Map<Integer, Integer> statesMap = new HashMap<>();
    BitSet newFinalStates = new BitSet();

    // add states
    for (int state : aut) {
      int newState = this.newVertex();
      statesMap.put(state, newState);
      if (aut.isFinalState(state)) {
        newFinalStates.set(newState);
      }
    }
    // add edges
    for (int state : aut) {
      int newSourceState = statesMap.get(state);
      for (Edge<EdgeInfo> oneOutEdge : aut.getOutEdges(state)) {
        int newTargetState = statesMap.get(oneOutEdge.getTarget());
        this.newEdge(oneOutEdge.getInfo(), newSourceState, newTargetState);
      }
    }

    // to make sure that there is only ONE final state, add epsilon edges from
    // the final states to a new final state
    int newFinalState = this.newVertex();
    int currentFinalState = -1;
    while((currentFinalState = newFinalStates.nextSetBit(currentFinalState + 1)) != -1) {
      this.newEdge(EPSILON, currentFinalState, newFinalState);
    }
    return new SubAutomaton(
      statesMap.get(aut.getInitialState()), newFinalState);
  }
/**
   * Adds the given finite automaton to this automaton and return a sub
   * automaton for accessing its initial and final states.<br>
   * The initial and final states of the automaton added are only available via
   * the returned sub automaton!
   *
   * @param aut
   *          the finite automaton to add
   * @return the corresponding sub automaton
   */
Adds the given finite automaton to this automaton and return a sub
automaton for accessing its initial and final states.
The initial and final states of the automaton added are only available via
the returned sub automaton!

@param aut
the finite automaton to add
@return the corresponding sub automaton
Adds the given finite automaton to this automaton and return a sub automaton for accessing its initial and final states . The initial and final states of the automaton added are only available via the returned sub automaton! @param aut the finite automaton to add @return the corresponding sub automaton
public SubAutomaton addAutomaton(FiniteAutomaton<EdgeInfo> aut) {
    Map<Integer, Integer> statesMap = new HashMap<>();
    BitSet newFinalStates = new BitSet();
    for (int state : aut) {
      int newState = this.newVertex();
      statesMap.put(state, newState);
      if (aut.isFinalState(state)) {
        newFinalStates.set(newState);
      }
    }
    for (int state : aut) {
      int newSourceState = statesMap.get(state);
      for (Edge<EdgeInfo> oneOutEdge : aut.getOutEdges(state)) {
        int newTargetState = statesMap.get(oneOutEdge.getTarget());
        this.newEdge(oneOutEdge.getInfo(), newSourceState, newTargetState);
      }
    }
    int newFinalState = this.newVertex();
    int currentFinalState = -1;
    while((currentFinalState = newFinalStates.nextSetBit(currentFinalState + 1)) != -1) {
      this.newEdge(EPSILON, currentFinalState, newFinalState);
    }
    return new SubAutomaton(
      statesMap.get(aut.getInitialState()), newFinalState);
  }
public SubAutomaton addAutomaton ( FiniteAutomaton < EdgeInfo > aut ) { Map < Integer , Integer > statesMap = new HashMap < > ( ) ; BitSet newFinalStates = new BitSet ( ) ; for ( int state : aut ) { int newState = this . newVertex ( ) ; statesMap . put ( state , newState ) ; if ( aut . isFinalState ( state ) ) { newFinalStates . set ( newState ) ; } } for ( int state : aut ) { int newSourceState = statesMap . get ( state ) ; for ( Edge < EdgeInfo > oneOutEdge : aut . getOutEdges ( state ) ) { int newTargetState = statesMap . get ( oneOutEdge . getTarget ( ) ) ; this . newEdge ( oneOutEdge . getInfo ( ) , newSourceState , newTargetState ) ; } } int newFinalState = this . newVertex ( ) ; int currentFinalState = - 1 ; while ( ( currentFinalState = newFinalStates . nextSetBit ( currentFinalState + 1 ) ) != - 1 ) { this . newEdge ( EPSILON , currentFinalState , newFinalState ) ; } return new SubAutomaton ( statesMap . get ( aut . getInitialState ( ) ) , newFinalState ) ; }
Adds the given finite automaton to this automaton and return a sub
 automaton for accessing its initial and final states.<br>
 The initial and final states of the automaton added are only available via
 the returned sub automaton!
Adds the given finite automaton to this automaton and return a sub automaton for accessing its initial and final states . <br > The initial and final states of the automaton added are only available via the returned sub automaton!
// add states // add edges // to make sure that there is only ONE final state, add epsilon edges from // the final states to a new final state