merge_states: don't call defrag_states if unnecessary

* spot/twa/twagraph.cc (merge_states): Return the number
of removed states, and use that to decide if defrag_states
is needed.
* spot/twa/twagraph.hh, NEWS: Document that.
* tests/core/tgbagraph.test, tests/core/twagraph.cc: Adjust test case.
This commit is contained in:
Alexandre Duret-Lutz 2021-07-13 10:20:14 +02:00
parent d019ea61fe
commit 4570c735f3
5 changed files with 40 additions and 12 deletions

View file

@ -1,6 +1,6 @@
#!/bin/sh
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2018, 2020 Laboratoire de Recherche et
# Copyright (C) 2014-2018, 2020, 2021 Laboratoire de Recherche et
# Développement de l'Epita (LRDE).
#
# This file is part of Spot, a model checking library.
@ -291,16 +291,20 @@ State: 2
[t] 0&1
--END--
HOA: v1
States: 1
Start: 0
States: 2
Start: 1
AP: 0
acc-name: all
Acceptance: 0 t
properties: trans-labels explicit-labels state-acc complete
properties: deterministic
--BODY--
State: 0
[t] 0
State: 1
[t] 0
[t] 0
[t] 0
[t] 0
--END--
EOF

View file

@ -1,5 +1,5 @@
// -*- coding: utf-8 -*-
// Copyright (C) 2014-2018 Laboratoire de Recherche et Développement
// Copyright (C) 2014-2019, 2021 Laboratoire de Recherche et Développement
// de l'Epita (LRDE).
//
// This file is part of Spot, a model checking library.
@ -167,14 +167,22 @@ static void f5()
auto s1 = tg->new_state();
auto s2 = tg->new_state();
auto s3 = tg->new_state();
auto s4 = tg->new_state();
auto s5 = tg->new_state();
tg->set_init_state(s3);
tg->set_init_state(s5);
tg->new_edge(s1, s2, bddtrue);
tg->new_edge(s2, s2, bddtrue);
tg->new_edge(s3, s2, bddtrue);
tg->new_edge(s4, s4, bddtrue);
tg->new_edge(s5, s1, bddtrue);
tg->new_edge(s5, s2, bddtrue);
tg->new_edge(s5, s3, bddtrue);
tg->new_edge(s5, s4, bddtrue);
tg->merge_states();
unsigned out = tg->merge_states();
std::cerr << out << '\n';
assert(out == 3);
spot::print_hoa(std::cout, tg) << '\n';
}