pex_altaccess.cpp
Go to the documentation of this file.
1/** @file pex_altaccess.cpp Example plugin */
2
3#include "pex_altaccess.h"
4#include <stack>
5
6namespace faudes {
7
8
9// we use the alternative accessibility algorithm from tutorial 6
10// for our example plugin.
11
13 // create a todo stack for state indices
14 std::stack<Idx> todo;
15 // create an empty StateSet for the set of accessible state
16 StateSet accessible_states;
17 // iterator for a StateSet
18 StateSet::Iterator sit;
19 // initialize the algorithm by pushing all initial states on the todo stack
20 for (sit = rGen.InitStatesBegin(); sit != rGen.InitStatesEnd(); ++sit) {
21 todo.push(*sit);
22 }
23 // process the todo stack until it's empty
24 while (not todo.empty()) {
25 // get and delete the next state index from the todo stack
26 const Idx current = todo.top();
27 todo.pop();
28 // insert the current state in the set of accessible states
29 accessible_states.Insert(current);
30 // create transition iterator for the states of the current state
31 TransSet::Iterator tit = rGen.TransRelBegin(current);
32 TransSet::Iterator tit_end = rGen.TransRelEnd(current);
33 // push successor states ton todo stack if not already discovered
34 while (tit != tit_end) {
35 if (not accessible_states.Exists(tit->X2)) {
36 todo.push(tit->X2);
37 }
38 ++tit;
39 }
40 }
41 // delete the states and transitions which are not accessible
42 rGen.DelStates(rGen.States() - accessible_states);
43}
44
45
46} // namespace faudes
TBaseSet< Transition, TransSort::X1EvX2 >::Iterator Iterator
StateSet::Iterator InitStatesBegin(void) const
TransSet::Iterator TransRelBegin(void) const
void DelStates(const StateSet &rDelStates)
TransSet::Iterator TransRelEnd(void) const
StateSet::Iterator InitStatesEnd(void) const
const StateSet & States(void) const
bool Exists(const T &rElem) const
void AlternativeAccessible(Generator &rGen)
uint32_t Idx

libFAUDES 2.34d --- 2026.03.11 --- c++ api documentaion by doxygen