17 #ifndef AWALI_ALGOS_DISTANCE_HH
18 # define AWALI_ALGOS_DISTANCE_HH
23 # include <unordered_set>
24 # include <unordered_map>
31 namespace awali {
namespace sttc {
36 template<
typename Aut>
45 std::queue<state_t> todo;
46 std::unordered_set<state_t> marked;
47 std::unordered_map<state_t, std::pair<state_t, transition_t>> parent;
57 for (
auto t : aut->in(p))
59 auto s = aut->src_of(t);
60 if (marked.find(s) == marked.end())
63 auto cur_p = parent.find(p);
65 if (cur_p == parent.end())
68 cur_d = cur_p->second.first + 1;
69 parent[s] = {cur_d, t};
79 template<
typename Aut>
80 std::vector<transition_t>
87 std::queue<state_t> todo;
88 std::unordered_set<state_t> marked;
89 std::unordered_map<state_t, std::pair<state_t, transition_t>> parent;
99 std::vector<transition_t> rpath;
101 while (bt_curr != start)
104 std::tie(bt_curr, t) = parent.find(bt_curr)->second;
107 std::reverse(rpath.begin(), rpath.end());
111 for (
auto t : aut->out(p))
113 auto s = aut->dst_of(t);
114 if (marked.find(s) == marked.end())
121 return std::vector<transition_t>();
std::unordered_map< state_t, std::pair< unsigned, transition_t > > paths_ibfs(const Aut &aut, std::vector< state_t > start)
Definition: distance.hh:40
std::vector< transition_t > path_bfs(const Aut &aut, state_t start, state_t end)
Definition: distance.hh:81
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
Definition: synchronizing_word.hh:266
Main namespace of Awali.
Definition: ato.hh:22
unsigned state_t
Definition: types.hh:21
unsigned transition_t
Definition: types.hh:22