101 using namespace Aleph;
114# define PRIMINFO(p) static_cast<Prim_Info<GT>*>(NODE_COOKIE(p))
115# define TREENODE(p) (PRIMINFO(p)->tree_node)
116# define HEAPNODE(p) (PRIMINFO(p)->heap_node)
118 template <
class GT,
class Distance>
129 template <
class GT,
class Distance>
251 typename GT::Arc *arc = it.get_current_arc_ne();
252 heap.
put_arc(arc, it.get_tgt_node_ne());
281 typename GT::Arc *arc = it.get_current_arc_ne();
285 typename GT::Node *tgt = it.get_tgt_node_ne();
318 typename GT::Arc *arc = it.get_current_arc_ne();
319 heap.
put_arc(arc, it.get_tgt_node_ne());
347 typename GT::Arc *arc = it.get_current_arc_ne();
351 typename GT::Node *tgt = it.get_tgt_node_ne();
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Arc heap for graph algorithms.
Default distance accessor for arc weights.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
bool is_empty() const noexcept
Node * get_first_node() const
Return any node in the graph.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
_Graph_Node Node
The graph type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
Functor that traverses the nodes of a graph and performs an operation.
Calcula el árbol abarcador mínimo de un grafo según el algoritmo de Prim.
void paint_min_spanning_tree(const GT &g, typename GT::Node *first)
void min_spanning_tree(const GT &g, typename GT::Node *first, GT &tree)
Prim_Min_Spanning_Tree(Distance __dist=Distance(), SA __sa=SA())
Constructor.
ArcHeap< GT, Distance, Acc_Simple_Heap > Simple_Heap
ArcHeap< GT, Distance, Acc_Heap > Heap
void operator()(const GT &g, GT &tree)
Invoca al cálculo del árbol abarcador mínimo por el algoritmo de Prim.
Prim_Heap_Info< GT, Distance > Acc_Heap
Simple_Prim_Heap< GT, Distance > Acc_Simple_Heap
Generic RAII scope guard for cleanup operations on graphs.
void put_arc(typename GT::Arc *arc, typename GT::Node *tgt)
Insert or update an arc associated with a target node, keeping the smallest-distance arc per node in ...
GT::Arc * get_min_arc()
Extract the arc with minimum distance from the heap and clear its node-to-heap mapping.
ArcInfo & get_info() noexcept
Return a modifiable reference to the arc data.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
void reset_arcs() const
Reset all the arcs of graph (the control bits, the state, the counter and the cookie)
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
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(Node *node, int bit) const noexcept
Reset the bit of node (to zero)
constexpr size_t get_num_arcs() const noexcept
void reset_nodes() const
Reset all the nodes of graph (the control bits, the state, the counter and the cookie)
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.
RAII guards for graph node/arc cookies.
List_Graph< Graph_Node< int >, Graph_Arc< int > > GT
#define IS_NODE_VISITED(p, bit)
Determine whether the control bit is set or not to one.
#define ARC_BITS(p)
Return the control bits of arc p.
#define NODE_COOKIE(p)
Return the node cookie
void clear_graph(GT &g) noexcept
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.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Default filter for filtered iterators on arcs.
Arc of graph implemented with double-linked adjacency lists.
void operator()(const GT &g, typename GT::Node *p)
Init_Prim_Info(GT &__tree)
Filtered iterator of adjacent arcs of a node.
void *& operator()(typename GT::Node *p)
void *& operator()(typename GT::Node *p)
void operator()(const GT &, typename GT::Node *p)
Array-based graph implementation.
Utility algorithms and operations for graphs.