scc.hh
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
00094 unsigned scc_count() const;
00095
00099 unsigned initial() const;
00100
00104 const succ_type& succ(unsigned n) const;
00105
00109 bool accepting(unsigned n) const;
00110
00114 const cond_set& cond_set_of(unsigned n) const;
00115
00122 bdd ap_set_of(unsigned n) const;
00123
00130 bdd aprec_set_of(unsigned n) const;
00131
00135 bdd acc_set_of(unsigned n) const;
00136
00141 bdd useful_acc_of(unsigned n) const;
00142
00149 const std::list<const state*>& states_of(unsigned n) const;
00150
00154 unsigned scc_of_state(const state* s) const;
00155
00157 unsigned self_loops() const;
00158
00159 protected:
00160 bdd update_supp_rec(unsigned state);
00161 int relabel_component();
00162
00163 struct scc
00164 {
00165 public:
00166 scc(int index) : index(index), acc(bddfalse),
00167 supp(bddtrue), supp_rec(bddfalse),
00168 trivial(true), useful_acc(bddfalse) {};
00170 int index;
00173 bdd acc;
00175 std::list<const state*> states;
00177 cond_set conds;
00179 bdd supp;
00181 bdd supp_rec;
00183 succ_type succ;
00185 bool trivial;
00187 bdd useful_acc;
00188 };
00189
00190 const tgba* aut_;
00191 typedef std::list<scc> stack_type;
00192 stack_type root_;
00193 std::stack<bdd> arc_acc_;
00194
00195 std::stack<bdd> arc_cond_;
00196
00197 typedef Sgi::hash_map<const state*, int,
00198 state_ptr_hash, state_ptr_equal> hash_type;
00199 hash_type h_;
00200
00201
00202
00203 int num_;
00204 typedef std::pair<const spot::state*, tgba_succ_iterator*> pair_state_iter;
00205 std::stack<pair_state_iter> todo_;
00206
00207
00208
00209
00210
00211
00212
00213
00214 typedef std::vector<scc> scc_map_type;
00215 scc_map_type scc_map_;
00216
00217
00218 unsigned self_loops_;
00219 };
00220
00221 scc_stats build_scc_stats(const tgba* a);
00222 scc_stats build_scc_stats(const scc_map& m);
00223
00224 std::ostream& dump_scc_dot(const tgba* a, std::ostream& out,
00225 bool verbose = false);
00226 std::ostream& dump_scc_dot(const scc_map& m, std::ostream& out,
00227 bool verbose = false);
00228 }
00229
00230 #endif // SPOT_TGBAALGOS_SCC_HH