91 template <
typename Node_Info = Empty_Class>
195 template <
typename Arc_Info = Empty_Class>
228 :
Base(src, tgt, data)
269 template <
typename __Graph_Node = Graph_Snode<
unsigned long>,
270 typename __Graph_Arc = Graph_Sarc<
unsigned long>>
272 :
public GraphCommon<List_SGraph<__Graph_Node, __Graph_Arc>,
273 __Graph_Node, __Graph_Arc>
333 : DynSetNode::Iterator(g.node_list)
381 return static_cast<Arc *
>(this->Iterator::get_curr_ne());
387 return static_cast<Arc *
>(this->Iterator::get_curr());
404 return static_cast<Node *
>(a->get_connected_node(src_node));
411 return static_cast<Node *
>(a->get_connected_node(src_node));
434 : DynSetArc::Iterator(
_g.arc_list)
448 return static_cast<Node *
>(get_current_arc_ne()->src_node);
454 return static_cast<Node *
>(get_current_arc_ne()->tgt_node);
489 assert(p->arc_list.is_empty());
499 Arc *arc =
static_cast<Arc *
>(a);
504 src->arc_list.append(a);
506 if (
not this->digraph
and src != tgt)
508 tgt->arc_list.append(a);
520 Node *src =
static_cast<Node *
>(arc->src_node);
521 Node *tgt =
static_cast<Node *
>(arc->tgt_node);
523 src->arc_list.remove_ne([arc](
auto a) {
return a == arc; });
526 if (
not this->digraph
and src != tgt)
528 tgt->arc_list.remove_ne([arc](
auto a) {
return a == arc; });
557 if (this->get_src_node(arc) == p
or this->get_tgt_node(arc) == p)
559 this->disconnect_arc(arc);
591 return static_cast<Arc *
>(p->arc_list.get_first());
612 template <
class Compare>
627 template <
class Compare>
654 template <
typename __Graph_Node = Graph_Snode<
int>,
655 typename __Graph_Arc = Graph_Sarc<
int>>
Exception handling system with formatted messages for Aleph-w.
#define ah_range_error_if(C)
Throws std::range_error if condition holds.
Generic directed graph (digraph) wrapper template.
Iterator on the items of list.
Dynamic singly linked list with functional programming support.
T & append(const T &item)
Append a new item by copy.
const Key & get_first() const
Key * append(const Key &key)
void swap(DynSetTree &dset) noexcept(noexcept(tree.swap(dset.tree)) and noexcept(std::swap(num_nodes, dset.num_nodes)) and noexcept(std::swap(arena_allocator, dset.arena_allocator)))
Exchange all elements of this set with dset in constant time (and extremely fast).
size_t remove(const Key &key)
Removes a key from the dynamic set.
void empty()
remove all elements from the set
Arc for graphs implemented with simple adjacency lists.
Graph_Sarc(const Arc_Info &info)
Graph_Sarc(const Graph_Sarc &arc)
Graph_Sarc(void *src, void *tgt, Arc_Info &&data)
Graph_Sarc & operator=(const Graph_Sarc &arc)
Graph_Sarc(void *src, void *tgt, const Arc_Info &data)
Graph_Sarc(Arc_Info &&info=Arc_Info())
Iterator over arcs of a graph.
Node * get_src_node_ne() const noexcept
Returns the source node of the current arc (only meaningful for digraphs)
Node * get_tgt_node() const
Returns the target node of the current arc (only meaningful for digraphs)
Arc * get_current_arc_ne() const noexcept
Returns a pointer to the current arc.
Node * get_tgt_node_ne() const noexcept
Returns the target node of the current arc (only meaningful for digraphs)
Arc * Item_Type
Data type returned by get_curr()
Arc * get_current_arc() const
Returns a pointer to the current arc.
Arc_Iterator(const List_SGraph &_g) noexcept
Node * get_src_node() const
Returns the source node of the current arc (only meaningful for digraphs)
Arc iterator for a graph node.
Arc * get_current_arc_ne() const noexcept
Node * get_tgt_node() const
Returns the target node of the current arc.
Node_Arc_Iterator()=default
Instantiate an empty (invalid) iterator.
Arc * Item_Type
Data type returned by get_curr()
Arc * get_curr() const
Return get_current_arc()
Node * Set_Type
The set type over which iteration is performed.
Node * get_tgt_node_ne() const noexcept
Returns the target node of the current arc.
Arc * get_current_arc() const
Arc * get_curr_ne() const noexcept
Return get_current_arc() without exception.
Node_Arc_Iterator(Node *src) noexcept
Instantiate an iterator over node src.
Node iterator for a graph.
Node * get_current_node_ne() const noexcept
Node * get_current_node() const
Returns the current node.
Node_Iterator(const List_SGraph &g) noexcept
Node * Item_Type
Data type returned by get_curr()
Graph class implemented with singly-linked adjacency lists.
DynSetArc arc_list
Set of arcs in the graph.
void sort_arcs(Compare &cmp)
Sort all arcs of the graph according to a comparison criteria.
Arc * insert_arc(Node *src, Node *tgt, void *a)
virtual void remove_node(Node *p) noexcept
void swap(List_SGraph &g) noexcept
DynSetNode node_list
Set of nodes in the graph.
Node * get_first_node() const
Arc * get_first_arc(Node *p) const
Returns the first arc of node p.
void disconnect_arc(Arc *arc)
void sort_arcs(Compare &&cmp=Compare())
typename Arc::Arc_Type Arc_Type
virtual void remove_arc(Arc *arc) noexcept
Removes the arc.
virtual Node * insert_node(Node *p)
Insertion of a node whose memory has already been allocated.
typename Node::Node_Type Node_Type
Arc * get_first_arc() const
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
Common methods for the arc of a graph.
Common attributes and methods for nodes (vertexes) belonging to graphs.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
Common methods to the Aleph-w ( ) graph classes.
Node * insert_node(const Node_Type &node_info)
Allocate a new node, set by copy its data content and insert it into the graph.
void common_swap(GT &g) noexcept
Arc * insert_arc(Node *src, Node *tgt, const Arc_Type &arc_info)
Create and insert a new arc linking two nodes and copying data.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
#define ALEPH_GRAPH_COPY_MOVE_CTORS(GraphClass)
Macro to generate copy/move constructors and assignment operators.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
void mergesort(T *a, const long l, const long r, std::vector< T > &buf, Compare cmp)
auto get_curr() const
Return the current tuple (bounds-checked).
auto get_curr_ne() const noexcept
Return the current tuple (no-throw variant).
DynList< T > maps(const C &c, Op op)
Classic map operation.
Node for graphs implemented with simple adjacency lists.
Graph_Snode(Node_Info &&info=Node_Info())
DynList< void * > arc_list
Adjacency list of arcs incident to this node.
Graph_Snode(const Graph_Snode &node)
Graph_Snode(const Node_Info &info)
Constructor that assigns an attribute value.
Graph_Snode & operator=(const Graph_Snode &node)
Graph_Snode(Graph_Snode *node)
Copy constructor from a node pointer.
Dynamic set implementations based on balanced binary search trees.
Generic graph and digraph implementations.