90 template <AlephGraph
GT,
115 return tree.are_connected(i, j);
137 template <
class G,
class GT_SA>
156 if (not
static_cast<bool>(
sa(a)))
189 arcs.append(it.get_current_arc_ne());
232 for (
typename GT::Node_Iterator it(g); it.has_curr(); it.next_ne())
234 auto gp = it.get_curr();
243 auto ga = it.get_current_arc_ne();
246 auto ta = tree.
insert_arc(tsrc, ttgt, ga->get_info());
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
C++20 concepts for the protocol shared by graph algorithms.
Standard functor implementations and comparison objects.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
static Array create_reserved(const size_t cap)
Build an empty array with room for at least cap items.
Default distance accessor for arc weights.
void next_ne() noexcept(shows_ne)
Advances the iterator to the next filtered element, as next() does.
Computes the minimum spanning tree of a graph using Kruskal's algorithm.
bool is_painted() const noexcept
Returns true if the spanning tree has been painted on the graph.
void paint_min_spanning_tree(const GT &g)
Paints the minimum spanning tree arcs on the graph.
Kruskal_Min_Spanning_Tree(Distance __dist=Distance(), SA __sa=SA())
Constructor.
void paint_min_spanning_tree(const GT &g, GT &tree)
Paints the MST on g and copies it to a separate tree graph.
static bool arc_is_in_tree(Fixed_Relation &tree, long i, long j) noexcept
void operator()(const GT &g, GT &tree)
Computes the minimum spanning tree using Kruskal's algorithm.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
_Graph_Arc Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Functor that traverses the nodes of a graph and performs an operation.
Binary relation between a set of integers.
constexpr size_t get_num_blocks() const noexcept
Return the number of connected blocks, which is the number of equivalence classes.
void join(size_t i, size_t j)
Insert the pair '(i,j)' in the relation.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
bool is_digraph() const noexcept
Return true if the graph this is directed.
static void map_arcs(A1 *p, A2 *q) noexcept
Map the arcs through their cookies.
void reset_bit_arcs(int bit) const noexcept
Reset bit to zero for all the arcs of graph.
constexpr size_t get_num_arcs() const noexcept
Return the number of arcs of the graph.
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
static void map_nodes(N1 *p, N2 *q) noexcept
Map the nodes through their cookies.
PredicateWith<F, Args...>, and neither the call nor the conversion of its result to bool can throw.
DynArray< Graph::Arc * > arcs
#define ARC_COOKIE(p)
Return the arc cookie
#define NODE_COUNTER(p)
Get the counter of a node.
#define ARC_BITS(p)
Return the control bits of arc p.
#define NODE_COOKIE(p)
Return the node cookie
void clear_graph(GT &g)
Clean a graph: all its nodes and arcs are removed and freed.
#define IS_ARC_VISITED(p, bit)
Determine whether the bit field is or not set to one.
#define NODE_BITS(p)
Get the control bits of a node.
Main namespace for Aleph-w library functions.
void timsort(T *a, const size_t n, const Compare &cmp=Compare())
Timsort — adaptive, stable, natural merge sort.
and
Check uniqueness with explicit hash + equality functors.
Filtered iterator on all the arcs of a graph.
Default filter for filtered iterators on arcs.
Comparison functor for arc weights/distances.
Helper struct for initializing node counters during DFS.
void operator()(const GT &, typename GT::Node *p) noexcept
Filter for arcs painted by Kruskal's algorithm.
bool operator()(typename G::Arc *a) const noexcept(NothrowPredicateWith< GT_SA &, typename G::Arc *& >)
Whether the filter of the caller shows a and a is painted as an arc of the spanning tree.
Array-based graph implementation.
Dynamic array container with automatic resizing.
Utility algorithms and operations for graphs.
Comprehensive sorting algorithms and search utilities for Aleph-w.
DAG (acyclic) graph testing.
Union-Find (Disjoint Set Union) data structure.