67# ifndef TPL_INDEXGRAPH
68# define TPL_INDEXGRAPH
116template <
class GT,
class Compare = Dft_Node_Cmp<GT>,
117 template <
class ,
class >
class Tree =
Treap>
147 return idx_node.insert_in_graph(info);
164 <<
"src node not in index";
167 <<
"tgt node not in index";
169 return idx_arc.insert_in_graph(src, tgt, info);
206 return idx_arc.search(src, tgt);
218 for (
typename GT::Node_Arc_Iterator it(p); it.has_curr(); it.next_ne())
221 for (
typename GT::Arc_Iterator it(
g); it.has_curr(); it.next_ne())
225 return idx_node.remove_from_graph(p);
231 return idx_arc.remove_from_graph(a);
241 template <AlephGraph GT>
inline
251 auto q = t2.search(p);
261 return g1.
all_arcs([idx = &t2, &g1] (
auto a)
265 auto s2 = mapped_node<GT>(s1);
266 auto t2 = mapped_node<GT>(t1);
267 auto a2 = idx->search(s2, t2);
270 return a2->get_info() == a->get_info();
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Index for fast arc lookup by its endpoint nodes.
Builds an index of nodes for fast search and retrieval.
Builds node and arc indices for fast lookup and retrieval.
size_t get_num_arcs() const
Returns the number of arcs the index contains.
GT_Node * search_node(GT_Node *p)
Looks up a node in the index.
GT_Node * search_node(const GT_Node_Type &info)
Looks up a node in the index.
IndexArc< GT, Tree > idx_arc
GT_Arc * search_arc(GT_Node *src, GT_Node *tgt)
Looks up an arc in the index given its two nodes.
void remove_node(GT_Node *p)
Removes node p from the graph and from the index.
size_t get_num_nodes() const
Returns the number of nodes the index contains.
GT_Node * insert_node(const GT_Node_Type &info)
Creates a new node and inserts it into the graph and the index.
IndexNode< GT, Compare, Tree > idx_node
void remove_arc(GT_Arc *a)
Removes arc a from the graph and from the index.
GT_Arc * insert_arc(GT_Node *src, GT_Node *tgt, const GT_Arc_Type &info=GT_Arc_Type())
Creates a new arc between two nodes and inserts it into the graph and the index.
GT::Node_Type GT_Node_Type
Index_Graph(GT &__g)
Creates an index of the graph: nodes and arcs are indexed.
typename Node::Node_Type Node_Type
The arc class type.
typename Arc::Arc_Type Arc_Type
The type of data stored in the arc.
Node * get_src_node(Arc *arc) const noexcept
Return the source node of arc (only for directed graphs)
bool is_digraph() const noexcept
Return true if the graph this is directed.
bool all_arcs(Operation &op) const
Check if all the arcs of graph satisfy a boolean condition.
bool all_nodes(Operation &op) const
Check if all the nodes of graph satisfy an boolean condition.
constexpr size_t vsize() const noexcept
See get_num_nodes().
size_t esize() const noexcept
Return the total of arcs of graph.
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
QuadTree - Hierarchical spatial index for 2D points.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
bool are_equal(const GT &g1, const GT &g2)
Fast graph comparison.
Treap (a special type of randomized binary search tree) using nodes without virtual destructor.
Arc indexing for fast lookup by endpoint nodes.
Node indexing for fast O(log n) lookup by key.