54 using namespace Aleph;
60 template <
typename Node_Info = Empty_Class>
166 for (
size_t i = 0; i < this->
num_arcs; ++i)
186 for (
size_t i = 0; i < this->
num_arcs; ++i)
222 template <
typename Arc_Info = Empty_Class>
257 :
Base(src, tgt, data)
262 Graph_Aarc(
void *src,
void *tgt, Arc_Info && data = Arc_Info())
270 template <
class __Graph_Node = Graph_Anode<
unsigned long>,
271 class __Graph_Arc = Graph_Aarc<
unsigned long>>
273 :
public GraphCommon<Array_Graph<__Graph_Node, __Graph_Arc>,
274 __Graph_Node, __Graph_Arc>
355 src->arc_array, src->arcs_dim, src->num_arcs),
383 return static_cast<Node *
>(a->get_connected_node(
src_node));
389 return static_cast<Node *
>(a->get_connected_node(
src_node));
407 it.get_curr()->compress();
415 aptr->src_node = src;
416 aptr->tgt_node = tgt;
417 src->insert_arc(
aptr);
423 tgt->insert_arc(
aptr);
425 catch (
const std::bad_alloc &)
427 src->remove_arc(
aptr);
437 catch (
const std::bad_alloc &)
439 src->remove_arc(
aptr);
441 tgt->remove_arc(
aptr);
465 catch (
const std::bad_alloc &)
479 Node *src =
static_cast<Node *
>(arc->src_node);
480 Node *tgt =
static_cast<Node *
>(arc->tgt_node);
482 src->remove_arc_ne(arc);
484 tgt->remove_arc_ne(arc);
508 for (
size_t i = 0, n = p->num_arcs; i < n; ++i)
532 return static_cast<Arc *
>(p->arc_array[0]);
615 template <
typename __Graph_Node = Graph_Anode<
int>,
616 typename __Graph_Arc = Graph_Aarc<
int>>
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
#define ah_bad_alloc_if(C)
Throws std::bad_alloc if condition holds.
#define ah_range_error_if(C)
Throws std::range_error if condition holds.
Iterator wrapper for C++ raw arrays and circular buffers.
Node_Arc_Iterator(Node *src) noexcept
Instantiate an iterator over node src.
Node * get_tgt_node_ne() const
Return the target node of the current arc.
Node * get_tgt_node() const
Node_Arc_Iterator() noexcept
Instantiate an empty (invalid) iterator.
Node * Set_Type
The set type over which iteration is performed.
Arc * get_current_arc_ne() const noexcept
Return the current arc.
Arc * Item_Type
The data type returned by get_curr().
Arc * get_curr_ne() const noexcept
Arc * get_current_arc() const
Return the current arc.
typename Arc::Arc_Type Arc_Type
virtual void remove_arc(Arc *a)
virtual Node * insert_node(Node *p)
void swap(Array_Graph &g) noexcept
Arc * get_first_arc(Node *p) const
Arc * disconnect_arc(Arc *arc)
Dlink & get_arc_dlink() noexcept
Returns reference to internal arc Dlink for sorting operations.
Arc * try_insert_arc(Node *src, Node *tgt, void *a)
virtual ~Array_Graph() noexcept
virtual void remove_node(Node *p)
Arc * get_first_arc() const
Node * get_first_node() const
Arc * insert_arc(Node *src, Node *tgt, void *a)
Arc * connect_arc(Arc *arc)
typename Node::Node_Type Node_Type
Dlink & get_node_dlink() noexcept
Returns reference to internal node Dlink for sorting operations.
Iterator wrapper for C++ raw arrays.
Generic directed graph (digraph) wrapper template.
Doubly linked circular list node.
Dlink * remove_first() noexcept
constexpr Dlink *& get_first() const noexcept
If this is a header node, it return the first node of this
constexpr bool is_empty() const noexcept
Return true if this (as header node) is empty.
void append(Dlink *node) noexcept
Insert node before this.
void swap(Dlink *link) noexcept
Swap this with list whose header is link.
Dynamic singly linked list with functional programming support.
T & append(const T &item)
Append a new item by copy.
Graph_Aarc(Arc_Info &&info=Arc_Info())
Graph_Aarc(const Arc_Info &info)
Graph_Aarc(void *src, void *tgt, const Arc_Info &data)
Graph_Aarc(const Graph_Aarc &arc)
Graph_Aarc(void *src, void *tgt, Arc_Info &&data=Arc_Info())
Graph_Aarc & operator=(const Graph_Aarc &arc)
Graph_Anode & operator=(const Graph_Anode &node)
void remove_arc(const void *arc)
static constexpr size_t Default_Cap
void * insert_arc(void *arc)
void remove_arc_ne(const void *arc) noexcept
Graph_Anode(Node_Info &&info)
size_t contract_threshold
void allocate_more(size_t new_size)
static constexpr size_t Contract_Factor
Graph_Anode(const Node_Info &info)
Graph_Anode(const Graph_Anode &node)
Graph_Anode(Graph_Anode *p)
void init(const size_t dim)
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.
size_t num_arcs
data associated to the node. Access it with get_info()
Common methods to the Aleph-w ( ) graph classes.
Container< Arc * > arcs() const
Return a container with all the arcs of the graph.
Node * insert_node(const Node_Type &node_info)
Allocate a new node, set by copy its data content and insert it into the graph.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
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.
constexpr size_t get_num_arcs() const noexcept
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
void remove_arcs_if(Predicate pred)
Remove all arcs matching a predicate.
__gmp_expr< typename __gmp_resolve_expr< T, V >::value_type, __gmp_binary_expr< __gmp_expr< T, U >, __gmp_expr< V, W >, __gmp_dim_function > > dim(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.
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Iterator over arcs of a graph.
Arc_Iterator(const Array_Graph &g)
bool operator()(Arc *a1, Arc *a2) const noexcept
Cmp_Arc(Cmp &&__cmp=Cmp())
Node_Iterator(const Array_Graph &g) noexcept
GTNodeIterator< Array_Graph > Base
Common arc iterator for graph having its arcs derived from Dlink class.
Common node iterator for graph having its node derived from Dlink class.
Dynamic set implementations based on balanced binary search trees.
Simple graph implementation with adjacency lists.