spot  1.0
cycles.hh
Go to the documentation of this file.
1 // Copyright (C) 2012 Laboratoire de Recherche et Developpement de
2 // l'Epita (LRDE).
3 //
4 // This file is part of Spot, a model checking library.
5 //
6 // Spot is free software; you can redistribute it and/or modify it
7 // under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // Spot is distributed in the hope that it will be useful, but WITHOUT
12 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
14 // License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 
19 #ifndef SPOT_TGBAALGOS_CYCLES_HH
20 # define SPOT_TGBAALGOS_CYCLES_HH
21 
22 #include "scc.hh"
23 #include "misc/hash.hh"
24 #include <deque>
25 
26 namespace spot
27 {
78  {
79  protected:
80  typedef Sgi::hash_set<const state*,
82 
83  // Extra information required for the algorithm for each state.
84  struct state_info
85  {
87  : reach(false), mark(false)
88  {
89  }
90  // Whether the state has already left the stack at least once.
91  bool reach;
92  // set to true when the state current state w is stacked, and
93  // reset either when the state is unstacked after having
94  // contributed to a cycle, or when some state z that (1) w could
95  // reach (even indirectly) without discovering a cycle, and (2)
96  // that a contributed to a contributed to a cycle.
97  bool mark;
98  // Deleted successors (in the paper, states deleted from A(x))
100  // Predecessors of the current states, that could not yet
101  // contribute to a cycle.
103  };
104 
105  // Store the state_info for all visited states.
106  typedef Sgi::hash_map<const state*, state_info,
109 
110  // A tagged_state s is a state* (s->first) associated to its
111  // state_info (s->second). We usually handled tagged_state in the
112  // algorithm to avoid repeated lookup of the state_info data.
113  typedef hash_type::iterator tagged_state;
114 
115  // The automaton we are working on.
116  const tgba* aut_;
117  // The SCC map built for aut_.
118  const scc_map& sm_;
119 
120  // The DFS stack. Each entry contains a tagged state, an iterator
121  // on the transitions leaving that state, and a Boolean f
122  // indicating whether this state as already contributed to a cycle
123  // (f is updated when backtracking, so it should not be used by
124  // cycle_found()).
125  struct dfs_entry
126  {
129  bool f;
130  };
131  typedef std::deque<dfs_entry> dfs_stack;
133 
134  public:
135  enumerate_cycles(const scc_map& map);
136  virtual ~enumerate_cycles() {}
137 
143  void run(unsigned scc);
144 
145 
158  virtual bool cycle_found(const state* start);
159 
160  private:
161  // introduce a new state to the tags map.
162  tagged_state tag_state(const state* s);
163  // add a new state to the dfs_ stack
164  void push_state(tagged_state ts);
165  // block the edge (x,y) because it cannot contribute to a new
166  // cycle currently (sub-procedure from the paper)
167  void nocycle(tagged_state x, tagged_state y);
168  // unmark the state y (sub-procedure from the paper)
169  void unmark(tagged_state y);
170  };
171 
172 }
173 
174 #endif // SPOT_TGBAALGOS_CYCLES_HH

Please comment this page and report errors about it on the RefDocComments page.
Generated on Sat Oct 27 2012 09:34:32 for spot by doxygen 1.8.1.2