spot  0.9.2
scc.hh
Go to the documentation of this file.
1 // Copyright (C) 2008, 2009, 2010, 2011 Laboratoire de Recherche et
2 // Developpement de l'Epita.
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 2 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 Spot; see the file COPYING. If not, write to the Free
18 // Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 // 02111-1307, USA.
20 
21 #ifndef SPOT_TGBAALGOS_SCC_HH
22 # define SPOT_TGBAALGOS_SCC_HH
23 
24 #include <map>
25 #include <stack>
26 #include <vector>
27 #include "tgba/tgba.hh"
28 #include <iosfwd>
29 #include "misc/hash.hh"
30 #include "misc/bddlt.hh"
31 
32 namespace spot
33 {
34 
35  struct scc_stats
36  {
38  unsigned scc_total;
40  unsigned acc_scc;
45  unsigned dead_scc;
46 
52  unsigned acc_paths;
56  unsigned dead_paths;
57  unsigned self_loops;
58 
60  std::vector<bool> useless_scc_map;
61 
66 
67  std::ostream& dump(std::ostream& out) const;
68  };
69 
71  class scc_map
72  {
73  public:
74  typedef std::map<unsigned, bdd> succ_type;
75  typedef std::set<bdd, bdd_less_than> cond_set;
76 
81  scc_map(const tgba* aut);
82 
83  ~scc_map();
84 
86  void build_map();
87 
89  const tgba* get_aut() const;
90 
96  unsigned scc_count() const;
97 
101  unsigned initial() const;
102 
106  const succ_type& succ(unsigned n) const;
107 
113  bool trivial(unsigned n) const;
114 
118  bool accepting(unsigned n) const;
119 
123  const cond_set& cond_set_of(unsigned n) const;
124 
131  bdd ap_set_of(unsigned n) const;
132 
139  bdd aprec_set_of(unsigned n) const;
140 
144  bdd acc_set_of(unsigned n) const;
145 
150  bdd useful_acc_of(unsigned n) const;
151 
158  const std::list<const state*>& states_of(unsigned n) const;
159 
166  const state* one_state_of(unsigned n) const;
167 
171  unsigned scc_of_state(const state* s) const;
172 
174  unsigned self_loops() const;
175 
176  protected:
177  bdd update_supp_rec(unsigned state);
178  int relabel_component();
179 
180  struct scc
181  {
182  public:
183  scc(int index) : index(index), acc(bddfalse),
184  supp(bddtrue), supp_rec(bddfalse),
185  trivial(true), useful_acc(bddfalse) {};
187  int index;
190  bdd acc;
192  std::list<const state*> states;
196  bdd supp;
198  bdd supp_rec;
202  bool trivial;
214  };
215 
216  const tgba* aut_; // Automata to decompose.
217  typedef std::list<scc> stack_type;
218  stack_type root_; // Stack of SCC roots.
219  std::stack<bdd> arc_acc_; // A stack of acceptance conditions
220  // between each of these SCC.
221  std::stack<bdd> arc_cond_; // A stack of conditions
222  // between each of these SCC.
223  typedef Sgi::hash_map<const state*, int,
225  hash_type h_; // Map of visited states. Values >= 0
226  // designate maximal SCC. Values < 0
227  // number states that are part of
228  // incomplete SCCs being completed.
229  int num_; // Number of visited nodes, negated.
230  typedef std::pair<const spot::state*, tgba_succ_iterator*> pair_state_iter;
231  std::stack<pair_state_iter> todo_; // DFS stack. Holds (STATE,
232  // ITERATOR) pairs where
233  // ITERATOR is an iterator over
234  // the successors of STATE.
235  // ITERATOR should always be
236  // freed when TODO is popped,
237  // but STATE should not because
238  // it is used as a key in H.
239 
240  typedef std::vector<scc> scc_map_type;
241  scc_map_type scc_map_; // Map of constructed maximal SCC.
242  // SCC number "n" in H_ corresponds to entry
243  // "n" in SCC_MAP_.
244  unsigned self_loops_; // Self loops count.
245  };
246 
247  scc_stats build_scc_stats(const tgba* a);
249 
250  std::ostream& dump_scc_dot(const tgba* a, std::ostream& out,
251  bool verbose = false);
252  std::ostream& dump_scc_dot(const scc_map& m, std::ostream& out,
253  bool verbose = false);
254 }
255 
256 #endif // SPOT_TGBAALGOS_SCC_HH

Please comment this page and report errors about it on the RefDocComments page.
Generated on Mon Jul 2 2012 17:35:47 for spot by doxygen 1.8.1.1