39# ifndef TPL_GRAPH_INDEXES_H
40# define TPL_GRAPH_INDEXES_H
116template <
class GT,
class Compare = Dft_Node_Cmp<GT>,
117 template <
typename,
class>
class Tree =
Treap,
152 this->
insert(it.get_curr());
190 if (this->
insert(p) ==
nullptr)
228 if (this->
insert(p) ==
nullptr)
330template <
class GT,
class Compare = Dft_Arc_Cmp<GT>,
331 template <
typename,
class>
class Tree =
Treap,
376 this->
insert(it.get_curr());
420 if (this->
insert(a) ==
nullptr)
475 std::swap(key->src_node, key->tgt_node);
487 ((tgt ==
found->src_node) && (src ==
found->tgt_node)));
Builds an arc index for fast lookup by source/target nodes.
GT::Node_Type GT_Node_Info
Typedef for the graph's node info type.
DynSetTree< typename GT::Arc *, Tree, Compare > Tree_Type
Typedef for the internal tree type.
GT_Arc * insert_in_graph(GT_Node *src, GT_Node *tgt, const GT_Arc_Info &&info=GT_Arc_Info())
Inserts an arc into the graph and index (rvalue overload).
GT_Arc * search(GT_Node *src, GT_Node *tgt, const GT_Arc_Info &info)
Searches for an arc by its source, target, and content.
GT_Arc * insert_in_graph(GT_Node *src, GT_Node *tgt, const GT_Arc_Info &info)
Inserts an arc into the graph and index.
SA & sa
Reference to the arc iterator filter object.
GT::Arc_Type GT_Arc_Info
Typedef for the graph's arc info type.
GT & g
Reference to the graph being indexed.
GT::Arc GT_Arc
Typedef for the graph's arc type.
GT::Node GT_Node
Typedef for the graph's node type.
GT_Arc * search(GT_Node *src, GT_Node *tgt, const GT_Arc_Info &&info=GT_Arc_Info())
Searches for an arc by its source, target, and content (rvalue overload).
void remove_from_graph(GT_Arc *a)
Removes an arc from the graph and index.
void init()
Initializes the index by inserting all arcs from the graph.
Arcs_Index(GT &_g, Compare &cmp, SA &_sa)
Constructor.
Arcs_Index(GT &_g, Compare &&cmp=Compare(), SA &&_sa=SA())
Constructor with default comparison and filter objects.
Dynamic set backed by balanced binary search trees with automatic memory management.
Key * insert(const Key &key)
Inserts a key into the dynamic set.
Key & find(const Key &key) const
Returns a modifiable reference to an element within the set.
size_t remove(const Key &key)
Removes a key from the dynamic set.
Key * search(const Key &key) const
Find an element in the set.
Key * search_or_insert(const Key &key)
Look for the key in the binary search tree or inserts it if it is not found.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
virtual void remove_node(Node *node) noexcept
Remove a node from the graph and free its memory.
typename Node::Node_Type Node_Type
The arc class type.
virtual void remove_arc(Arc *arc) noexcept
Remove an arc from the graph and free it.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
typename Arc::Arc_Type Arc_Type
The type of data stored in the arc.
Filtered iterator on the nodes of a graph.
Builds a node index for fast lookup and retrieval.
GT & g
Reference to the graph being indexed.
Nodes_Index(GT &_g, Compare &&cmp=Compare(), SN &&_sn=SN())
Constructor with rvalue references for comparison and filter.
GT::Node_Type GT_Node_Info
Typedef for the graph's node info type.
GT::Node GT_Node
Typedef for the graph's node type.
GT_Node * search_or_insert_in_graph(GT_Node *p)
Searches for a node in the index and graph, inserting it if not found.
void remove_from_graph(GT_Node *p)
Removes a node from the graph and index.
GT_Node * insert_in_graph(const GT_Node_Info &&info=GT_Node_Info())
Inserts a node with generic content into the graph and index (rvalue overload).
void init()
Initialize the index by inserting all existing graph nodes.
GT_Node * search(const GT_Node_Info &info)
Searches for a node by its content (info overload).
GT_Node * insert_in_graph(GT_Node *p)
Inserts a node into the graph and index.
Nodes_Index(GT &_g, Compare &cmp, SN &_sn)
Constructor that initializes the index with existing graph nodes.
GT_Node * search(GT_Node *p)
Searches for a node by its content.
DynSetTree< GT_Node *, Tree, Compare > Tree_Type
Typedef for the internal tree type.
SN & sn
Reference to the node iterator filter object.
GT_Node * search_or_insert_in_graph(const GT_Node_Info &info)
Searches for a node with generic content in the index and graph, inserting it if not found.
GT_Node * insert_in_graph(const GT_Node_Info &info)
Inserts a node with generic content into the graph and index.
Aleph::DynList< __T > maps(Operation &op) const
Map the elements of the container.
void * tgt_node
Please don't use.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
bool is_digraph() const noexcept
Return true if the graph this is directed.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
Main namespace for Aleph-w library functions.
DynList< T > maps(const C &c, Op op)
Classic map operation.
Filtered iterator on all the arcs of a graph.
Default arc comparison class for Arcs_Index.
bool operator()(typename GT::Arc *a1, typename GT::Arc *a2) const
Comparison operator.
Default node comparison class for Nodes_Index.
bool operator()(typename GT::Node *p1, typename GT::Node *p2) const
Comparison operator.
Default filter for filtered iterators on arcs.
Default filter for the graph nodes.
Arc of graph implemented with double-linked adjacency lists.
Treap (a special type of randomized binary search tree) using nodes without virtual destructor.
Dynamic set implementations based on balanced binary search trees.
Generic graph and digraph implementations.