17 template <
typename Aut>
52 return it->second.get_weight();
54 return aut_->weightset()->max();
64 auto p =
states_.emplace(s, elt);
75 return it->second.get_parent();
77 return automaton_t::element_type::null_state();
85 return it->second.get_parent();
87 return automaton_t::element_type::null_state();
112 template <
typename Aut>
119 using handle_t =
typename queue_t::handle_type;
120 auto handles = std::unordered_map<state_t_of<automaton_t>, handle_t>{};
123 auto queue = queue_t{};
124 auto& src_node = predecessor_tree.
get_node_of(predecessor_tree.get_root());
126 src_node.set_depth(0);
127 handles[src_node.get_state()] = queue.emplace(src_node);
129 const auto& ws = *aut->weightset();
130 while (!queue.empty())
132 auto current = std::move(queue.top());
134 auto s = current.get_state();
136 const auto curr_weight = current.get_weight();
137 const auto curr_depth = current.get_depth();
139 for (
auto tr :
all_in(aut, s))
141 auto& neighbor = predecessor_tree.
get_node_of(aut->src_of(tr));
146 auto new_dist = ws.mul(curr_weight, aut->weight_of(tr));
147 if (ws.less(new_dist, dist))
149 neighbor.set_weight(new_dist);
150 neighbor.set_depth(curr_depth + 1);
151 neighbor.set_parent(s);
152 auto p = handles.emplace(neighbor.get_state(), handle_t{});
154 p.first->second = queue.emplace(neighbor);
156 queue.update(p.first->second);
160 return predecessor_tree;
state_t get_parent_of(state_t s) const
dijkstra_node_t & get_node_of(state_t s)
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
shortest_path_tree< Aut > compute_shortest_path_tree(const Aut &aut, state_t_of< Aut > src)
Compute the shortest path tree of aut starting from src.
weight_t_of< automaton_t > weight_t
weight_t get_weight() const
If there is no weight in the node then its weight is the weightset's maximum.
typename detail::state_t_of_impl< base_t< ValueSet > >::type state_t_of
weight_t get_weight_of(state_t s)
void set_weight(weight_t weight)
dijkstra_node_t & operator[](state_t s)
typename detail::weightset_t_of_impl< base_t< ValueSet > >::type weightset_t_of
typename detail::weight_t_of_impl< base_t< ValueSet > >::type weight_t_of
dijkstra_node< automaton_t > dijkstra_node_t
state_t_of< automaton_t > state_t
boost::heap::fibonacci_heap< Elt, detail::comparator_t< Elt > > min_fibonacci_heap
std::unordered_map< state_t, dijkstra_node_t > dijkstra_map_t
Dijkstra Node implementation.
state_t get_parent_of(state_t s)
void set_parent_of(state_t s, state_t parent)
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
void add(const dijkstra_node_t &n)
shortest_path_tree(const automaton_t &aut, state_t root)