tgbagraph: add a merge_transitions() method.

* src/graph/graph.hh: Add some framework to erase transitions, and
defrag the resulting transitions_ vector on demand.  Also remove
the nb_states() and nb_transitions() because num_states() and
num_transitions() already exist.
* src/graphtest/graph.cc, src/graphtest/ngraph.cc: Adjust to
use num_states().
* src/tgba/tgbagraph.hh (merge_transitions): New method.
* src/misc/hash.hh: Add a pair_hash class, needed by
merge_transitions().
* src/graphtest/tgbagraph.cc, src/graphtest/tgbagraph.test: Add states
for transitions removal and merge_transitions().
This commit is contained in:
Alexandre Duret-Lutz 2014-05-21 19:16:50 +02:00
parent 9909699c63
commit 424de90385
7 changed files with 286 additions and 10 deletions

View file

@ -44,6 +44,7 @@ void f1()
auto s1 = g.new_state();
auto s2 = g.new_state();
auto s3 = g.new_state();
g.new_transition(s1, s1, bddfalse, bddfalse);
g.new_transition(s1, s2, p1, bddfalse);
g.new_transition(s1, s3, p2, !a1 & a2);
g.new_transition(s2, s3, p1 & p2, a1 & !a2);
@ -52,6 +53,36 @@ void f1()
g.new_transition(s3, s3, bddtrue, (!a1 & a2) | (a1 & !a2));
spot::dotty_reachable(std::cout, &tg);
{
auto i = g.out_iteraser(s3);
++i;
i.erase();
i.erase();
assert(!i);
spot::dotty_reachable(std::cout, &tg);
}
{
auto i = g.out_iteraser(s3);
i.erase();
assert(!i);
spot::dotty_reachable(std::cout, &tg);
}
g.new_transition(s3, s1, p1 | p2, (!a1 & a2) | (a1 & !a2));
g.new_transition(s3, s2, p1 >> p2, bddfalse);
g.new_transition(s3, s1, bddtrue, (!a1 & a2) | (a1 & !a2));
std::cerr << tg.num_transitions() << '\n';
assert(tg.num_transitions() == 7);
spot::dotty_reachable(std::cout, &tg);
tg.merge_transitions();
spot::dotty_reachable(std::cout, &tg);
std::cerr << tg.num_transitions() << '\n';
assert(tg.num_transitions() == 5);
}
int main()