spot  1.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
scc.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013 Laboratoire de
3 // Recherche et Développement de l'Epita.
4 //
5 // This file is part of Spot, a model checking library.
6 //
7 // Spot is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Spot is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 #ifndef SPOT_TGBAALGOS_SCC_HH
21 # define SPOT_TGBAALGOS_SCC_HH
22 
23 #include <map>
24 #include <stack>
25 #include <vector>
26 #include "tgba/tgba.hh"
27 #include <iosfwd>
28 #include "misc/hash.hh"
29 #include "misc/bddlt.hh"
30 
31 namespace spot
32 {
33 
34  struct SPOT_API scc_stats
35  {
37  unsigned scc_total;
39  unsigned acc_scc;
44  unsigned dead_scc;
45 
51  unsigned acc_paths;
55  unsigned dead_paths;
56  unsigned self_loops;
57 
59  std::vector<bool> useless_scc_map;
60 
65 
66  std::ostream& dump(std::ostream& out) const;
67  };
68 
70  class SPOT_API scc_map
71  {
72  public:
73  typedef std::map<unsigned, bdd> succ_type;
74  typedef std::set<bdd, bdd_less_than> cond_set;
75 
80  scc_map(const tgba* aut);
81 
82  ~scc_map();
83 
85  void build_map();
86 
88  const tgba* get_aut() const;
89 
95  unsigned scc_count() const;
96 
100  unsigned initial() const;
101 
105  const succ_type& succ(unsigned n) const;
106 
112  bool trivial(unsigned n) const;
113 
117  bool accepting(unsigned n) const;
118 
122  const cond_set& cond_set_of(unsigned n) const;
123 
134  bdd ap_set_of(unsigned n) const;
135 
142  bdd aprec_set_of(unsigned n) const;
143 
147  bdd acc_set_of(unsigned n) const;
148 
153  bdd useful_acc_of(unsigned n) const;
154 
161  const std::list<const state*>& states_of(unsigned n) const;
162 
169  const state* one_state_of(unsigned n) const;
170 
174  unsigned scc_of_state(const state* s) const;
175 
177  unsigned self_loops() const;
178 
179  protected:
180  bdd update_supp_rec(unsigned state);
181  int relabel_component();
182 
183  struct scc
184  {
185  public:
186  scc(int index) : index(index), acc(bddfalse),
187  supp(bddtrue), supp_rec(bddfalse),
188  trivial(true), useful_acc(bddfalse) {};
190  int index;
193  bdd acc;
195  std::list<const state*> states;
197  cond_set conds;
199  bdd supp;
201  bdd supp_rec;
203  succ_type succ;
205  bool trivial;
217  };
218 
219  const tgba* aut_; // Automata to decompose.
220  typedef std::list<scc> stack_type;
221  stack_type root_; // Stack of SCC roots.
222  std::stack<bdd> arc_acc_; // A stack of acceptance conditions
223  // between each of these SCC.
224  std::stack<bdd> arc_cond_; // A stack of conditions
225  // between each of these SCC.
226  typedef Sgi::hash_map<const state*, int,
227  state_ptr_hash, state_ptr_equal> hash_type;
228  hash_type h_; // Map of visited states. Values >= 0
229  // designate maximal SCC. Values < 0
230  // number states that are part of
231  // incomplete SCCs being completed.
232  int num_; // Number of visited nodes, negated.
233  typedef std::pair<const spot::state*, tgba_succ_iterator*> pair_state_iter;
234  std::stack<pair_state_iter> todo_; // DFS stack. Holds (STATE,
235  // ITERATOR) pairs where
236  // ITERATOR is an iterator over
237  // the successors of STATE.
238  // ITERATOR should always be
239  // freed when TODO is popped,
240  // but STATE should not because
241  // it is used as a key in H.
242 
243  typedef std::vector<scc> scc_map_type;
244  scc_map_type scc_map_; // Map of constructed maximal SCC.
245  // SCC number "n" in H_ corresponds to entry
246  // "n" in SCC_MAP_.
247  unsigned self_loops_; // Self loops count.
248  };
249 
250  SPOT_API scc_stats
251  build_scc_stats(const tgba* a);
252  SPOT_API scc_stats
253  build_scc_stats(const scc_map& m);
254 
255  SPOT_API std::ostream&
256  dump_scc_dot(const tgba* a, std::ostream& out, bool verbose = false);
257  SPOT_API std::ostream&
258  dump_scc_dot(const scc_map& m, std::ostream& out, bool verbose = false);
259 }
260 
261 #endif // SPOT_TGBAALGOS_SCC_HH

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Sat Dec 6 2014 12:28:44 for spot by doxygen 1.8.4