91 template <
typename Node_Info = Empty_Class>
195 template <
typename Arc_Info = Empty_Class>
228 :
Base(src, tgt, data)
234 :
Base(src, tgt,
std::move(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>
282 __Graph_Node, __Graph_Arc>;
285 __Graph_Node, __Graph_Arc>;
340 : DynSetNode::Iterator(
const_cast<DynSetNode &
>(g.node_list))
348 return this->DynSetNode::Iterator::get_curr_ne();
354 return this->DynSetNode::Iterator::get_curr();
404 return static_cast<Arc *
>(this->Iterator::get_curr_ne());
410 return static_cast<Arc *
>(this->Iterator::get_curr());
427 return static_cast<Node *
>(a->get_connected_node(src_node));
434 return static_cast<Node *
>(a->get_connected_node(src_node));
464 : DynSetArc::Iterator(
const_cast<DynSetArc &
>(_g.arc_list))
472 return this->DynSetArc::Iterator::get_curr_ne();
478 return this->DynSetArc::Iterator::get_curr();
490 return static_cast<Node *
>(get_current_arc_ne()->src_node);
496 return static_cast<Node *
>(get_current_arc_ne()->tgt_node);
534 assert(p->arc_list.is_empty());
554 Arc *arc =
static_cast<Arc *
>(a);
559 const bool in_tgt = not this->digraph
and src != tgt;
560 auto is_arc = [a](
void *x) {
return x == a; };
562 src->arc_list.append(a);
566 tgt->arc_list.append(a);
570 src->arc_list.remove_ne(is_arc);
580 src->arc_list.remove_ne(is_arc);
582 tgt->arc_list.remove_ne(is_arc);
596 Node *src =
static_cast<Node *
>(arc->src_node);
597 Node *tgt =
static_cast<Node *
>(arc->tgt_node);
599 src->arc_list.remove_ne([arc](
auto a) {
return a == arc; });
602 if (not this->digraph
and src != tgt)
604 tgt->arc_list.remove_ne([arc](
auto a) {
return a == arc; });
637 arc_list.
for_each([
this, &arcs_to_remove, p](
auto arc)
639 if (this->get_src_node(arc) == p or this->get_tgt_node(arc) == p)
640 arcs_to_remove.
append(arc);
643 arcs_to_remove.
for_each([
this](
auto a)
645 this->disconnect_arc(a);
671 return static_cast<Arc *
>(p->arc_list.get_first());
702 template <
typename __Graph_Node = Graph_Snode<
int>,
703 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.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
const Key & get_first() const
See min.
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.
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.
Arc * get_curr() const
Returns the current arc.
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 * get_curr_ne() const noexcept
Returns the current arc without checking that there is one.
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_curr() const
Returns the current node.
Node * get_current_node_ne() const noexcept
Node * get_curr_ne() const noexcept
Returns the current node without checking that there is one.
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.
Arc * insert_arc(Node *src, Node *tgt, void *a)
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)
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.
virtual void remove_node(Node *p)
Removes the node and its arcs, and frees them.
typename Node::Node_Type Node_Type
Arc * get_first_arc() const
void for_each(Operation &operation) const
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.
#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.
auto get_curr_ne() const noexcept(zip_detail::nothrow_curr_copy< Aleph::const_iterator_t< HeadC >, T > and zip_detail::nothrow_item_copy< T > and zip_detail::nothrow_tail_curr< ZipIterator< TailC... > >)
Return the current tuple (unchecked variant).
auto get_curr() const
Return the current tuple (bounds-checked).
and
Check uniqueness with explicit hash + equality functors.
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.