17 template <
typename Aut>
24 using map_t = std::unordered_map<state_t, node_t>;
54 return aut_->weightset()->max();
56 return it->second.get_weight();
66 auto p =
states_.emplace(s, elt);
77 return aut_->null_state();
79 return it->second.get_parent();
104 using handle_t =
typename queue_t::handle_type;
105 auto handles = std::unordered_map<state_t_of<automaton_t>, handle_t>{};
107 auto queue = queue_t{};
110 src_node.set_depth(0);
111 handles[src_node.get_state()] = queue.emplace(src_node);
113 const auto& ws = *
aut_->weightset();
114 while (!queue.empty())
116 auto current = std::move(queue.top());
118 auto s = current.get_state();
121 const auto curr_weight = current.get_weight();
122 const auto curr_depth = current.get_depth();
131 auto new_dist = ws.mul(curr_weight,
aut_->weight_of(t));
132 if (ws.less(new_dist, dist))
134 neighbor.set_weight(new_dist);
135 neighbor.set_depth(curr_depth + 1);
136 neighbor.set_parent(s);
137 auto p = handles.emplace(neighbor.get_state(), handle_t{});
139 p.first->second = queue.emplace(neighbor);
141 queue.update(p.first->second);
152 template <
typename Aut>
ATTRIBUTE_PURE bool has(const boost::container::flat_set< Key, Compare, Allocator > &s, const Key &e)
Whether e is member of s.
typename detail::weightset_t_of_impl< base_t< ValueSet > >::type weightset_t_of
weight_t_of< automaton_t > weight_t
void set_parent_of(state_t s, state_t parent)
node_t & get_node_of(state_t s)
typename detail::state_t_of_impl< base_t< ValueSet > >::type state_t_of
shortest_path_tree(const automaton_t &aut, state_t root)
state_t_of< automaton_t > state_t
weight_t get_weight() const
If there is no weight in the node then its weight is the weightset's maximum.
node_t & operator[](state_t s)
weight_t get_weight_of(state_t s) const
void add(const node_t &n)
auto all_in(const Aut &aut, state_t_of< Aut > s)
Indexes of transitions entering state s.
shortest_path_tree< Aut > make_shortest_path_tree(const Aut &aut, state_t_of< Aut > root)
Dijkstra Node implementation.
state_t get_parent_of(state_t s) const
boost::heap::fibonacci_heap< Elt, detail::comparator_t< Elt > > min_fibonacci_heap
std::unordered_map< state_t, node_t > map_t
typename detail::weight_t_of_impl< base_t< ValueSet > >::type weight_t_of
void compute_()
Compute the shortest path tree of aut_ starting from root_.