randomize: new function

* src/tgbaalgos/randomize.cc, src/tgbaalgos/randomize.hh: New files.
* src/tgbaalgos/Makefile.am: Add them.
* src/graph/graph.hh (rename_states_): New method.
* src/bin/autfilt.cc: Add options --randomize and --seed.
* src/tgbatest/randomize.test: Test them.
* src/tgbatest/Makefile.am: Add randomize.test.
* NEWS: Mention randomize().
This commit is contained in:
Alexandre Duret-Lutz 2014-12-03 14:16:45 +01:00
parent 0db0eca14e
commit c0e9891246
8 changed files with 257 additions and 7 deletions

View file

@ -725,6 +725,21 @@ namespace spot
//dump_storage(std::cerr);
}
// Rename all the states in the transition vector. The
// transitions_ vector is left in a state that is incorrect and
// should eventually be fixed by a call to chain_transitions_()
// before any iteration on the successor of a state is performed.
void rename_states_(const std::vector<unsigned>& newst)
{
assert(newst.size() == states_.size());
unsigned tend = transitions_.size();
for (unsigned t = 1; t < tend; t++)
{
transitions_[t].dst = newst[transitions_[t].dst];
transitions_[t].src = newst[transitions_[t].src];
}
}
void defrag_states(std::vector<unsigned>&& newst, unsigned used_states)
{
assert(newst.size() == states_.size());