23 template <
typename Ctx>
24 mutable_automaton<Ctx>
27 require(0 < num_states,
"num_states must be > 0");
31 automaton_t
res = make_shared_ptr<automaton_t>(
ctx);
33 std::vector<state_t> states;
34 states.reserve(num_states);
36 for (
unsigned i = 0; i < num_states; ++i)
37 states.push_back(res->new_state());
39 for (
unsigned i = 0; i < num_states; ++i)
42 for (
auto l : ctx.labelset()->generators())
44 auto dest = (la || i == num_states - 1) ? (i + 1) % num_states : i;
45 res->add_transition(states[i], states[dest], l,
46 ctx.weightset()->one());
51 res->set_initial(states[0]);
52 res->set_final(states[0]);
62 template <
typename Ctx,
typename>
66 const auto& c = ctx->
as<Ctx>();
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
auto & as()
Downcast to the exact type.
Template-less root for contexts.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
mutable_automaton< Ctx > cerny(const Ctx &ctx, unsigned num_states)
Cerny automata are automata whose synchronizing word length is always (n - 1)^2, the upper bound of t...
automaton cerny(const context &ctx, unsigned num_states)
Bridge.