121template <AlephGraph
GT,
160 if constexpr (std::is_integral_v<Distance_Type>)
163 a < std::numeric_limits<Distance_Type>::min() + b)
164 <<
"Integer underflow in distance subtraction: " << a <<
" - " << b;
167 a > std::numeric_limits<Distance_Type>::max() + b)
168 <<
"Integer overflow in distance subtraction: " << a <<
" - " << b;
185 auto arc = it.get_curr();
214 for (
typename GT::Arc_Iterator it(
copy_g); it.has_curr(); it.next_ne())
222 for (
typename GT::Arc_Iterator it(
orig); it.has_curr(); it.next_ne())
233 <<
"Arc mapping mismatch between original and copied graph";
240 <<
"Arc mapping mismatch between original and copied graph";
246 <<
"Original graph not available";
256 <<
"Node not found in mapping";
260 for (; it.has_curr()
and it.has_current_arc(); it.next())
264 <<
"Arc not found in mapping";
296 h =
bf.compute_nodes_weights();
320 requires std::is_convertible_v<typename GT::Arc_Type, Distance_Type>
340 return std::numeric_limits<Distance_Type>::infinity();
361 requires std::is_convertible_v<typename GT::Arc_Type, Distance_Type>
413 std::numeric_limits<Distance_Type>::infinity());
Bellman-Ford algorithm for single-source shortest paths.
Dijkstra's 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
Bellman-Ford algorithm for shortest paths with negative weights.
Default distance accessor for arc weights.
Spanning tree calculation of all shortest paths from a given node according to Dijkstra's algorithm.
Doubly-linked list (defined in tpl_dynList.H).
Generic key-value map implemented on top of a binary search tree.
Pair * append(const Key &key, const Data &data)
Pair * search(const Key &key) const noexcept
Collect all keys.
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
Data & find(const Key &key)
Find the value associated with key.
const size_t & size() const
Returns the cardinality of the set.
void empty()
remove all elements from the set
Graph copy with explicit node mapping.
Johnson's algorithm for all-pairs shortest paths.
Path< GT > find_path(Node *src, Node *tgt)
Find the shortest path from source to target.
static Distance_Type checked_add(const Distance_Type &a, const Distance_Type &b)
GraphCopyWithMapping< GT > graph_copy
Copy of graph with node mapping.
GT & get_reweighted_graph() noexcept
Get access to the internal reweighted graph.
DynMapTree< Node *, Node * > copy_to_orig_node
bool is_initialized() const noexcept
Check if the algorithm has been initialized.
DynMapTree< std::pair< Node *, Node * >, Distance_Type > compute_all_pairs_distances()
Compute the shortest distance for all pairs.
Distance_Type get_potential(Node *node) const
Get the node potential (h value) for a node.
static Distance_Type checked_sub(const Distance_Type &a, const Distance_Type &b)
Johnson(const GT &g, Distance d=Distance(), SA __sa=SA())
Construct a Johnson's all-pairs shortest paths executor.
typename Distance::Distance_Type Distance_Type
Johnson()=default
Default constructor (uninitialized state)
Path< GT > map_copy_path_to_original(const Path< GT > ©_path) const
Node * get_copy_node(Node *orig) const
Get the copy of a node in the reweighted graph.
Distance_Type get_distance(Node *src, Node *tgt)
Get the shortest distance from source to target.
void reweight_arcs()
Reweight all arcs using node potentials.
void build_reverse_mappings(const GT &orig)
const GT & get_reweighted_graph() const noexcept
Get const access to the internal reweighted graph.
DynMapTree< Arc *, Arc * > copy_to_orig_arc
DynMapTree< Node *, Distance_Type > h
Node potentials from Bellman-Ford.
Graph_Node< Node_Info > Node
The graph type.
Graph_Arc< Arc_Info > Arc
The node class type.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
#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().
T checked_add(const T &a, const T &b)
Safely add two distance values with overflow checking.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
Filtered iterator on all the arcs of a graph.
Default filter for filtered iterators on arcs.
typename Johnson::Distance_Type Distance_Type
Distance_Type operator()(Arc *arc) const
Filtered iterator of adjacent arcs of a node.
Alias for htlist.H (DynList implementation).
Generic graph and digraph implementations.