Logo Search packages:      
Sourcecode: lttoolbox version File versions  Download package

set< int > Transducer::closure ( int const   state,
int const   epsilon_tag = 0 
)

Returns the epsilon closure of a given state

Parameters:
state the state
epsilon_tag the tag to take as epsilon
Returns:
the epsilon-connected states

Definition at line 207 of file Transducer.C.

References transitions.

Referenced by determinize().

{
  set<int> nonvisited, result;
  
  nonvisited.insert(state);
  result.insert(state);

  while(nonvisited.size() > 0)
  {
    int auxest = *nonvisited.begin();
    pair<multimap<int, int>::iterator, multimap<int, int>::iterator> rango;
    rango = transitions[auxest].equal_range(epsilon_tag);
    while(rango.first != rango.second)
    {
      if(result.find(rango.first->second) == result.end())
      {
        result.insert(rango.first->second);
        nonvisited.insert(rango.first->second);
      }
      rango.first++;
    }
    nonvisited.erase(auxest);
  }

  return result;
}


Generated by  Doxygen 1.6.0   Back to index