1 #ifndef VCSN_ALGOS_DE_BRUIJN_HH
2 # define VCSN_ALGOS_DE_BRUIJN_HH
16 template <
typename Context>
17 mutable_automaton<Context>
20 const auto& gens = ctx.labelset()->genset();
21 size_t sz = std::distance(std::begin(gens), std::end(gens));
22 require(2 <= sz,
"de_bruijn: the alphabet needs at least 2 letters");
23 using context_t = Context;
25 automaton_t res = make_shared_ptr<automaton_t>(ctx);
27 auto init = res->new_state();
28 res->set_initial(init);
30 res->new_transition(init, init, l);
32 auto prev = res->new_state();
33 res->new_transition(init, prev, *std::begin(gens));
37 auto next = res->new_state();
39 res->new_transition(prev, next, l);
55 template <
typename Ctx,
typename Un
signed>
59 const auto& c = ctx->as<Ctx>();
70 #endif // !VCSN_ALGOS_DE_BRUIJN_HH
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::shared_ptr< detail::mutable_automaton_impl< Context >> mutable_automaton
std::shared_ptr< const detail::context_base > context
mutable_automaton< Context > de_bruijn(const Context &ctx, unsigned n)
automaton de_bruijn(const dyn::context &ctx, unsigned n)
Bridge.
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.