3 #include <boost/optional.hpp>
17 template <Automaton Aut,
typename Tag = auto_tag>
18 std::vector<transition_t_of<Aut>>
24 template <Automaton Aut>
25 std::vector<transition_t_of<Aut>>
29 if (weightset_t_of<Aut>::has_lightening_weights())
38 template <Automaton Aut,
typename Tag>
39 std::vector<transition_t_of<Aut>>
48 template <Automaton Aut>
49 std::vector<transition_t_of<Aut>>
51 const std::string& algo)
54 using path_t = std::vector<transition_t_of<Aut>>;
58 "lightest-path algorithm",
60 {
"auto", detail::lightest_path_tag<Aut, auto_tag>},
61 {
"a-star", detail::lightest_path_tag<Aut, a_star_tag>},
62 {
"bellman-ford", detail::lightest_path_tag<Aut, bellman_ford_tag>},
63 {
"dijkstra", detail::lightest_path_tag<Aut, dijkstra_tag>},
64 {
"yen", detail::lightest_path_tag<Aut, yen_tag>},
67 return map[algo](aut, src, dst);
74 template <Automaton Aut>
80 -> boost::optional<typename detail::word_polynomialset_t<context_t_of<Aut>>::monomial_t>
83 const auto& pls = *ps.labelset();
84 const auto& pws = *ps.weightset();
85 const auto& ls = *aut->labelset();
88 for (
auto t =
path[dst]; t != aut->null_transition();
89 t =
path[aut->src_of(t)])
91 w = pws.mul(aut->weight_of(t), w);
92 auto nl = aut->label_of(t);
93 if (!ls.is_special(nl))
95 if (aut->src_of(t) == src)
auto make_word_polynomialset(const Ctx &ctx) -> word_polynomialset_t< Ctx >
The polynomialset of words of a labelset (not necessarily on words itself).
Tag to request the most appropriate version of an algorithm.
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
typename detail::transition_t_of_impl< base_t< ValueSet >>::type transition_t_of
A mapping from strings to Values.
std::vector< transition_t_of< Aut > > lightest_path_tag(const Aut &aut, state_t_of< Aut > src, state_t_of< Aut > dst)
Tag-based dispatch on implementation.
auto path_monomial(const Aut &aut, const std::vector< transition_t_of< Aut >> &path, state_t_of< Aut > src=Aut::element_type::pre(), state_t_of< Aut > dst=Aut::element_type::post()) -> boost::optional< typename detail::word_polynomialset_t< context_t_of< Aut >>::monomial_t >
Given a path (typically computed by lightest_path), the corresponding monomial (label, weight).
std::vector< transition_t_of< Aut > > lightest_path(const Aut &aut, state_t_of< Aut > source, state_t_of< Aut > dest, a_star_tag)
Paths in filesystems, i.e., file names.