103# include <type_traits>
124template <AlephGraph GT, ArcDistance<GT> Distance = Dft_Dist<GT>>
134 auto dx = std::abs(f.x - t.x);
135 auto dy = std::abs(f.y - t.y);
171template <AlephGraph
GT,
183 static_assert(std::is_arithmetic_v<Distance_Type>,
184 "IDA* requires arithmetic distance type");
192 std::numeric_limits<Distance_Type>::max();
211 <<
"IDA*: heuristic must be non-negative, got " <<
h;
213 std::numeric_limits<Distance_Type>::max() -
h)
214 <<
"IDA*: overflow computing g_cost + heuristic";
225 Node * node =
nullptr;
244 auto arc = it.get_current_arc();
252 <<
"IDA*: negative weight " <<
w <<
" not allowed";
254 <<
"IDA*: overflow computing g_cost + w";
345 threshold =
res.value;
A* shortest path algorithm.
Exception handling system with formatted messages for Aleph-w.
#define ah_overflow_error_if(C)
Throws std::overflow_error if condition holds.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
C++20 concepts for the protocol shared by graph algorithms.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
Default distance accessor for arc weights.
IDA* algorithm for memory-efficient shortest path search.
typename Distance::Distance_Type Distance_Type
IDA_Star(Distance dist=Distance(), Heuristic h=Heuristic(), SA _sa=SA())
Constructor.
Distance_Type operator()(const GT &g, Node *start, Node *end, Path< GT > &path)
Finds shortest path (operator interface).
Distance_Type find_path(const GT &g, Node *start, Node *end, Path< GT > &path)
Finds the shortest path from start to end using IDA*.
static constexpr Distance_Type Inf
SearchResult search(const GT &g, Node *curr, Node *end, Distance_Type g_cost, Distance_Type threshold, Path< GT > &path)
Recursive DFS bounded by threshold.
Graph_Node< Node_Info > Node
The graph type.
Graph_Arc< Arc_Info > Arc
The node class type.
void empty()
Clean the path: all the nodes and arc are removed.
void set_graph(const GT &__g, Node *start_node=nullptr)
Set the graph of the path.
void append(Arc *arc)
Append an arc to the path.
Node * remove_last_node()
Remove the last node of path.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
void reset_bit_nodes(int bit) const noexcept
Reset bit to zero for all the nodes of graph.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
Node * get_connected_node(Arc *arc, Node *node) const noexcept
Return the adjacent node to node through arc.
#define IS_NODE_VISITED(p, bit)
Determine whether the control bit is set or not to one.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
#define NODE_BITS(p)
Get the control bits of a node.
Main namespace for Aleph-w library functions.
Chebyshev (L-infinity) distance heuristic for 8-connected grids.
Distance_Type operator()(typename GT::Node *from, typename GT::Node *to) const
typename Distance::Distance_Type Distance_Type
Default filter for filtered iterators on arcs.
Filtered iterator of adjacent arcs of a node.
Default heuristic for A* (zero heuristic, degrades to Dijkstra).
Utility algorithms and operations for graphs.