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:
parent
d019ea61fe
commit
4570c735f3
5 changed files with 40 additions and 12 deletions
|
|
@ -289,7 +289,7 @@ namespace spot
|
|||
g_.chain_edges_();
|
||||
}
|
||||
|
||||
void twa_graph::merge_states()
|
||||
unsigned twa_graph::merge_states()
|
||||
{
|
||||
if (!is_existential())
|
||||
throw std::runtime_error(
|
||||
|
|
@ -379,7 +379,10 @@ namespace spot
|
|||
else
|
||||
s = -1U;
|
||||
|
||||
defrag_states(remap, st);
|
||||
unsigned merged = num_states() - st;
|
||||
if (merged)
|
||||
defrag_states(remap, st);
|
||||
return merged;
|
||||
}
|
||||
|
||||
void twa_graph::purge_unreachable_states(shift_action* f, void* action_data)
|
||||
|
|
|
|||
|
|
@ -579,8 +579,19 @@ namespace spot
|
|||
///
|
||||
/// The implementation will sort the edges of the automaton to
|
||||
/// ease the comparison between two states. This may miss some
|
||||
/// self-loop based in non-deterministic automata.
|
||||
void merge_states();
|
||||
/// self-loop equivalences in non-deterministic automata.
|
||||
///
|
||||
/// States whose input have been redirected as a consequence of a
|
||||
/// merge are removed from the automaton. This procedure
|
||||
/// therefore renumber states.
|
||||
///
|
||||
/// Merging states might create duplicate transitions in the
|
||||
/// automaton. For instance (1)-a->(2) and (1)-a->(3) will become
|
||||
/// (1)-a->(1) and (1)-a->(1) if (1), (2) and (3) are merged into
|
||||
/// (1).
|
||||
///
|
||||
/// \return the number of states that have been merged and removed.
|
||||
unsigned merge_states();
|
||||
|
||||
/// \brief Remove all dead states
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue