autfilt: implement --complement

* src/bin/autfilt.cc: Add option --complete.
* src/twaalgos/complete.cc: Better handling of 0-edge automata.
* src/tests/complement.test: New file.
* src/tests/Makefile.am: Add it.
This commit is contained in:
Alexandre Duret-Lutz 2015-10-15 13:58:20 +02:00
parent 6cf807da6e
commit 2ae1b6a6f0
5 changed files with 136 additions and 0 deletions

View file

@ -23,6 +23,11 @@ namespace spot
{
unsigned complete_here(twa_graph_ptr aut)
{
// We do not use the initial state, but calling
// get_init_state_number() may create it and change the number of
// states. This has to be done before calling aut->num_states().
unsigned init = aut->get_init_state_number();
unsigned n = aut->num_states();
unsigned sink = -1U;
@ -69,6 +74,11 @@ namespace spot
unsigned t = aut->num_edges();
// If the automaton is empty,
// pretend that state
if (t == 0)
sink = init;
// Now complete all states (excluding any newly added the sink).
for (unsigned i = 0; i < n; ++i)
{