Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef SPOT_TGBAALGOS_SCC_HH
00022 # define SPOT_TGBAALGOS_SCC_HH
00023
00024 #include <map>
00025 #include <stack>
00026 #include <vector>
00027 #include "tgba/tgba.hh"
00028 #include <iosfwd>
00029 #include "misc/hash.hh"
00030 #include "misc/bddlt.hh"
00031
00032 namespace spot
00033 {
00034
00035 struct scc_stats
00036 {
00038 unsigned scc_total;
00040 unsigned acc_scc;
00045 unsigned dead_scc;
00046
00052 unsigned acc_paths;
00056 unsigned dead_paths;
00057 unsigned self_loops;
00058
00060 std::vector<bool> useless_scc_map;
00061
00065 bdd useful_acc;
00066
00067 std::ostream& dump(std::ostream& out) const;
00068 };
00069
00071 class scc_map
00072 {
00073 public:
00074 typedef std::map<unsigned, bdd> succ_type;
00075 typedef std::set<bdd, bdd_less_than> cond_set;
00076
00081 scc_map(const tgba* aut);
00082
00083 ~scc_map();
00084
00086 void build_map();
00087
00089 const tgba* get_aut() const;
00090
00096 unsigned scc_count() const;
00097
00101 unsigned initial() const;
00102
00106 const succ_type& succ(unsigned n) const;
00107
00113 bool trivial(unsigned n) const;
00114
00118 bool accepting(unsigned n) const;
00119
00123 const cond_set& cond_set_of(unsigned n) const;
00124
00131 bdd ap_set_of(unsigned n) const;
00132
00139 bdd aprec_set_of(unsigned n) const;
00140
00144 bdd acc_set_of(unsigned n) const;
00145
00150 bdd useful_acc_of(unsigned n) const;
00151
00158 const std::list<const state*>& states_of(unsigned n) const;
00159
00166 const state* one_state_of(unsigned n) const;
00167
00171 unsigned scc_of_state(const state* s) const;
00172
00174 unsigned self_loops() const;
00175
00176 protected:
00177 bdd update_supp_rec(unsigned state);
00178 int relabel_component();
00179
00180 struct scc
00181 {
00182 public:
00183 scc(int index) : index(index), acc(bddfalse),
00184 supp(bddtrue), supp_rec(bddfalse),
00185 trivial(true), useful_acc(bddfalse) {};
00187 int index;
00190 bdd acc;
00192 std::list<const state*> states;
00194 cond_set conds;
00196 bdd supp;
00198 bdd supp_rec;
00200 succ_type succ;
00202 bool trivial;
00204 bdd useful_acc;
00205 };
00206
00207 const tgba* aut_;
00208 typedef std::list<scc> stack_type;
00209 stack_type root_;
00210 std::stack<bdd> arc_acc_;
00211
00212 std::stack<bdd> arc_cond_;
00213
00214 typedef Sgi::hash_map<const state*, int,
00215 state_ptr_hash, state_ptr_equal> hash_type;
00216 hash_type h_;
00217
00218
00219
00220 int num_;
00221 typedef std::pair<const spot::state*, tgba_succ_iterator*> pair_state_iter;
00222 std::stack<pair_state_iter> todo_;
00223
00224
00225
00226
00227
00228
00229
00230
00231 typedef std::vector<scc> scc_map_type;
00232 scc_map_type scc_map_;
00233
00234
00235 unsigned self_loops_;
00236 };
00237
00238 scc_stats build_scc_stats(const tgba* a);
00239 scc_stats build_scc_stats(const scc_map& m);
00240
00241 std::ostream& dump_scc_dot(const tgba* a, std::ostream& out,
00242 bool verbose = false);
00243 std::ostream& dump_scc_dot(const scc_map& m, std::ostream& out,
00244 bool verbose = false);
00245 }
00246
00247 #endif // SPOT_TGBAALGOS_SCC_HH