Number states using negative values and SCCs using nonnegative

values.

Before this change states were numbered using positive values and
SCCs using negative values.  That meant the user had to work with
negative values.  With this changes, the nonnegative values used
to label SCCs can also directly be used as index in the scc_map_.

* src/tgbaalgos/scc.hh (scc_map::scc_of_state,
scc_map::cond_set_of, scc_map::acc_set_of, scc_map::states_of,
scc_map::initial, scc_map::scc_type, scc_map::succ,
scc_map::accepting): Adjust prototypes to take or return unsigned
arguments.
* src/tgbaalgos/scc.cc: Adjust prototypes of the above functions.
(scc_map::build_map, scc_map::relabel_component): Number states
using negative values, and SCCs using nonnegative values.
(dump_scc_dot): Adjust to use nonnegative values.
This commit is contained in:
Alexandre Duret-Lutz 2009-05-28 14:02:42 +02:00
parent 96a7a49c52
commit 15b3b9e07d
3 changed files with 62 additions and 44 deletions

View file

@ -60,29 +60,31 @@ namespace spot
class scc_map
{
public:
typedef std::map<int, bdd> succ_type;
typedef std::map<unsigned, bdd> succ_type;
typedef std::set<bdd, bdd_less_than> cond_set;
scc_map(const tgba* aut);
void build_map();
int relabel_component();
int scc_of_state(const state* s) const;
const cond_set& cond_set_of(int n) const;
bdd acc_set_of(int n) const;
const std::list<const state*>& states_of(int n) const;
const tgba* get_aut() const;
unsigned scc_count() const;
int initial() const;
unsigned initial() const;
const succ_type& succ(int i) const;
bool accepting(int i) const;
const succ_type& succ(unsigned n) const;
bool accepting(unsigned n) const;
const cond_set& cond_set_of(unsigned n) const;
bdd acc_set_of(unsigned n) const;
const std::list<const state*>& states_of(unsigned n) const;
unsigned scc_of_state(const state* s) const;
protected:
int relabel_component();
struct scc
{
public:
@ -109,8 +111,11 @@ namespace spot
// between each of these SCC.
typedef Sgi::hash_map<const state*, int,
state_ptr_hash, state_ptr_equal> hash_type;
hash_type h_; // Map of visited states.
int num_; // Number of visited nodes.
hash_type h_; // Map of visited states. Values >= 0
// designate maximal SCC. Values < 0
// number states that are part of
// incomplete SCCs being completed.
int num_; // Number of visited nodes, negated.
typedef std::pair<const spot::state*, tgba_succ_iterator*> pair_state_iter;
std::stack<pair_state_iter> todo_; // DFS stack. Holds (STATE,
// ITERATOR) pairs where
@ -124,7 +129,7 @@ namespace spot
typedef std::vector<scc> scc_map_type;
scc_map_type scc_map_; // Map of constructed maximal SCC.
// SCC number "n" in H_ corresponds to entry
// "-n-1" in SCC_MAP_.
// "n" in SCC_MAP_.
};
scc_stats build_scc_stats(const tgba* a);