#include<sttc/core/mutable_automaton.hh>
Namespace: awali::sttc

1. Basics

The main implementation of automata in Awali is called mutable automaton. It is implemented as a template class; automata are handled through shared pointers. Hence, the public type for automata in Awali is mutable_automaton<Context>, and every method is accessible with operator ->.
State and transition identifiers are unsigned int; for readability, there exist aliases state_t and transition_t

Factory:

    template <typename Context>
    mutable_automaton<Context>
    make_mutable_automaton(const Context& ctx);

The Context type which is a parameter of an automaton implies a number of types defined in the automaton class (left column) and that are accessible from the mutable_automaton<Context> type (right collumn):
context_t context_t_of<mutable automaton>
label_t label_t_of<mutable automaton>
labelset_t labelset_t_of<mutable automaton>
weight_t weight_t_of<mutable automaton>
weightset_t weightset_t_of<mutable automaton>
    const context_t& context() const;
    const weightset_ptr& weightset() const;
    const labelset_ptr& labelset() const;

2. Statistics

    size_t num_states() const;

    size_t num_transitions() const;

    size_t num_initials() const;

    size_t num_finals() const;
    state_t max_state() const;
    states_output_t
    states() const;

    transitions_output_t
    transitions() const;
states_output_t and transitions_output_t are internal types; which are "facades" in front of the automaton structure. They are containers with the minimal API which allows to use the C++ 11 forall syntax, for instance
    for(state_t s : aut->states())
      //...

3. State status

    state_t add_state();
Create a new state in the automaton.
    bool has_state(state_t s);
Test whether the state exists.
    void del_state(state_t s);
Delete the state. There are assert testing that the state id is valid and that the state is different from the pre-initial and the post-final states.
    bool is_initial(state_t s);
    bool is_final(state_t s);
Test whether the state is initial (resp. final). There is an assert testing that the state id is valid.
    void set_initial(state_t s, weight_t w);
    weight_t add_initial(state_t s, weight_t w);
    void set_initial(state_t s);
    void unset_initial(state_t s);

    void set_final(state_t s, weight_t w);
    weight_t add_final(state_t s, weight_t w);
    void set_final(state_t s);
    void unset_final(state_t s);
Change the initial (resp. final) status of the state. There is an assert testing that the state id is valid. The same semantic holds for methods dealing with final status.
    weight_t get_initial_weight(state_t s);

    weight_t get_final_weight(state_t s);
Gets the initial (resp. final) weight of the state, weightset()->zero() if the state is not initial (resp. final). There is an assert testing that the state id is valid.
    transitions_s_output_t
    initial_transitions() const;

    transitions_s_output_t
    final_transitions() const;
transitions_s_output_t is an internal type which is a "facade" in front of the automaton structure. It is a container with the minimal API which allows to use the C++ 11 forall syntax.

4. Transitions

    bool has_transition(transition_t tr) const;	
    bool has_transition(state_t src, state_t dst, label_t l) const;
    transition_t get_transition(state_t src, state_t dst, label_t l) const;
has_transition tests whether there exists such a transition; the potential transition can be characterized either by its identifier tr or by a tuple specifying its ends and label (src, dst, l).
get_transition(src, dst, l) returns the identifier of the specified transition.
There are assert testing that src and dst are valid state identifiers.
If there is no transition (src, dst, l), get_transition(src, dst, l) returns an invalid transition identifier. The identifier of the transition.
    transition_t set_transition(state_t src, state_t dst, label_t l, weight_t w);
    transition_t new_transition(state_t src, state_t dst, label_t l, weight_t w);
    weight_t add_transition(state_t src, state_t dst, label_t l, weight_t w);

    template <typename Aut>
    transition_t set_transition_copy(state_t src, state_t dst,
			         const Aut& aut, transition_t tr);
    template <typename Aut>
    transition_t new_transition_copy(state_t src, state_t dst,
			         const Aut& aut, transition_t tr);
    template <typename Aut>
    weight_t add_transition_copy(state_t src, state_t dst,
			         const Aut& aut, transition_t tr);

    transition_t set_transition(state_t src, state_t dst, label_t l);
    transition_t new_transition(state_t src, state_t dst, label_t l);
    weight_t add_transition(state_t src, state_t dst, label_t l);
Create or modify transitions. The transition can be specied by its ends (src,dst), its label l, and its weight w.
It can also be refered to a transition of another automaton; the transition is then set (resp. created, added) with the same label and the same weight.
If the weight is not specified, the behaviour is equivalent to specify the weight weightset()->one().
    void del_transition(transition_t tr);
    transition_t del_transition(state_t src, state_t dst, label_t l);
    void del_transition(state_t src, state_t dst);
Remove transitions.
If the transition is specified by its identifier, there is an assert that the identifier is valid; if the transition is specified by its ends, all the transitions with these ends are removed.
    state_t src_of(transition_t tr) const;
    state_t dst_of(transition_t tr) const;
    label_t label_of(transition_t tr) const;
    weight_t weight_of(transition_t tr) const;
Characteristics of transition.
    weight_t set_weight(transition_t tr, weight_t w);
    weight_t add_weight(transition_t tr, weight_t w);
    weight_t lmul_weight(transition_t tr, weight_t w);
    weight_t rmul_weight(transition_t tr, weight_t w);
Modify the weight of a transition.
set_weight sets the weight of a transition to w.
add_weight adds w to the weight of a transition.
lmul_weight multiply the weight of the transition by w to the left.
rmul_weight multiply the weight of the transition by w to the right.

5. History and state names

    const std::string& get_state_name(state_t s) const;
    std::ostream& print_state_name(state_t s, std::ostream& o) const;
    bool has_explicit_name(state_t s) const;
    void set_state_name(state_t s, const std::string& n);
    state_t get_state_by_name(const std::string& name) const;
history_t
history_t history() const;
void set_history(history_t h);
void strip_history();
std::ostream& print_state_history(state_t s, std::ostream& o) const;
bool has_history(state_t s) const;

6. Hidden states and transitions

   state_t pre();
   state_t post();
The identifiers of the pre-initial and the post-final states are usually 0 and 1.
size_t num_all_states() const;
    states_output_t all_states() const;

    transitions_output_t all_transitions() const;

    const tr_cont_t& all_out(state_t s) const;
    const tr_cont_t& all_in(state_t s) const;