63 template <
class GT,
class D>
66 using type =
decltype(std::declval<typename concepts_detail::defer<GT, D>::type::Node_Iterator &>().
get_curr());
73 template <
class GT,
class D>
76 using type =
decltype(std::declval<typename concepts_detail::defer<GT, D>::type::Arc_Iterator &>().
get_curr());
83 template <
class GT,
class D>
86 using type =
decltype(std::declval<typename concepts_detail::defer<GT, D>::type::Node_Arc_Iterator &>().
get_curr());
193template <
typename It>
196 { cit.has_curr() } -> std::convertible_to<bool>;
197 { it.
next() } -> std::same_as<void>;
213template <
typename It>
232template <
typename It,
typename Node>
235 { cit.get_curr() } -> std::convertible_to<Node*>;
251template <
typename It,
typename Arc>
254 { cit.get_curr() } -> std::convertible_to<Arc*>;
275template <
typename It,
typename Node,
typename Arc>
278 { cit.get_tgt_node() } -> std::convertible_to<Node*>;
319 return static_cast<Node *
>(Dlink::Iterator::get_curr_ne());
359 : Dlink::Iterator(head)
366 return static_cast<Arc *
>(Dlink::Iterator::get_curr_ne());
370 Arc *
get_curr()
const {
return static_cast<Arc *
>(Dlink::Iterator::get_curr()); }
408template <
class GT,
class Cmp>
435template <
class GT,
class Cmp>
452 Arc *arc1 =
static_cast<Arc *
>(d1);
453 Arc *arc2 =
static_cast<Arc *
>(d2);
454 return cmp(arc1, arc2);
475template <
typename NodeInfo>
568template <
typename ArcInfo>
623 arc_info = std::move(other.arc_info);
658template <
class GT,
class Node,
class Arc>
661 GT *
me() {
return static_cast<GT *
>(
this); }
688 std::swap(
cookie, g.cookie);
781 return static_cast<Node *
>(arc->src_node);
787 return static_cast<Node *
>(arc->tgt_node);
822 return static_cast<Node *
>(arc->get_connected_node(node));
832 return node->num_arcs;
1041 template <
class N1,
class N2 = N1>
1045 assert(p !=
nullptr and q !=
nullptr);
1072 template <
class A1,
class A2 = A1>
1076 assert(p !=
nullptr and q !=
nullptr);
1213 template <
typename... Args>
1243 std::unique_ptr<Arc> arc(
new Arc(arc_info));
1245 return arc.release();
1273 std::unique_ptr<Arc> arc(
new Arc(std::forward<Arc_Type>(arc_info)));
1275 return arc.release();
1299 template <
typename... Args>
1351 template <
class Operation>
1355 for (
typename GT::Node_Iterator it(*
const_me()); it.has_curr(); it.
next_ne())
1356 if (not op(it.get_curr()))
1362 template <
class Operation>
1418 template <
class Operation>
1422 for (
typename GT::Arc_Iterator it(*
const_me()); it.has_curr(); it.
next_ne())
1423 if (not op(it.get_curr()))
1429 template <
class Operation>
1487 template <
class Operation>
1491 for (
typename GT::Node_Arc_Iterator it(p); it.has_curr(); it.
next_ne())
1492 if (not op(it.get_curr()))
1498 template <
class Operation>
1529 template <
class Operation>
1533 for (
typename GT::Node_Iterator it(*
const_me()); it.has_curr(); it.
next_ne())
1534 operation(it.get_curr());
1538 template <
class Operation>
1569 template <
class Operation>
1573 for (
typename GT::Arc_Iterator it(*
const_me()); it.has_curr(); it.
next_ne())
1578 template <
class Operation>
1618 template <
class Operation>
1622 for (
typename GT::Node_Arc_Iterator it(p); it.has_curr(); it.
next_ne())
1627 template <
class Operation>
1663 template <
class Operation>
1671 template <
class Operation>
1707 template <
class Operation>
1715 template <
class Operation>
1754 template <
class Operation>
1762 template <
class Operation>
1808 template <
typename T = Node_Type,
class Op>
1809 requires std::is_invocable_r_v<T, Op &, Node *>
1856 template <
typename T = Arc_Type,
class Op>
1857 requires std::is_invocable_r_v<T, Op &, Arc *>
1908 template <
typename T = Arc_Type,
class Op>
1909 requires std::is_invocable_r_v<T, Op &, Arc *>
1954 template <
typename T = Node_Type,
class Op>
1955 requires std::is_invocable_r_v<T, Op &, const T &, Node *>
1997 template <
typename T = Arc_Type,
class Op>
1998 requires std::is_invocable_r_v<T, Op &, const T &, Arc *>
2041 template <
typename T = Arc_Type,
class Op>
2042 requires std::is_invocable_r_v<T, Op &, const T &, Arc *>
2076 DynList<Node *> ret;
2204 template <
class Operation>
2212 template <
class Operation>
2237 template <
class Operation>
2245 template <
class Operation>
2274 template <
class Operation>
2282 template <
class Operation>
2303 template <
class Operation>
2311 template <
class Operation>
2332 template <
class Operation>
2340 template <
class Operation>
2354 template <
class Operation>
2362 template <
class Operation>
2385 template <
class Operation = std::function<
bool(Node*)>>
2410 template <
class Operation = std::function<
bool(Arc*)>>
2425 template <
class Operation = std::function<
bool(Arc*)>>
2450 template <
typename T =
double,
class Extract>
2451 requires requires(
T &
sum, Extract &extract,
Arc *a) {
sum += extract(a); }
2460 template <
typename T =
double>
2464 for_each_arc(p, [&sum](
Arc *a) { sum +=
static_cast<T
>(a->get_info()); });
2483 template <
class Compare = std::function<
bool(Arc*, Arc*)>>
2486 return a->get_info() < b->get_info();
2489 Arc* result =
nullptr;
2491 if (result ==
nullptr or
cmp(a, result))
2512 template <
class Compare = std::function<
bool(Arc*, Arc*)>>
2515 return a->get_info() < b->get_info();
2518 Arc* result =
nullptr;
2520 if (result ==
nullptr or
cmp(result, a))
2531 template <
class Compare = std::function<
bool(Arc*, Arc*)>>
2534 return a->get_info() < b->get_info();
2537 Arc* result =
nullptr;
2539 if (result ==
nullptr or
cmp(a, result))
2550 template <
class Compare = std::function<
bool(Arc*, Arc*)>>
2553 return a->get_info() < b->get_info();
2556 Arc* result =
nullptr;
2558 if (result ==
nullptr or
cmp(result, a))
2579 template <
class Operation>
2583 DynList<Node*> yes, no;
2590 return {std::move(yes), std::move(no)};
2603 template <
class Operation>
2607 DynList<Arc*> yes, no;
2614 return {std::move(yes), std::move(no)};
2632 DynList<Node*> result;
2659 for (
typename GT::Node_Iterator it(*
const_me()); it.has_curr(); it.
next_ne())
2661 auto p = it.get_curr();
2689 return search_node([&info](
auto p) {
return p->get_info() == info; });
2712 for (
typename GT::Arc_Iterator it(*
const_me()); it.has_curr(); it.
next_ne())
2714 auto a = it.get_curr();
2742 return search_arc([&info](
auto a) {
return a->get_info() == info; });
2763 template <
class Operation>
2767 for (
typename GT::Node_Arc_Iterator it(p); it.has_curr(); it.
next_ne())
2769 Arc *arc = it.get_curr();
2777 template <
class Operation>
2809 for (
typename GT::Node_Arc_Iterator it(src); it.has_curr(); it.
next_ne())
2810 if (it.get_tgt_node_ne() == tgt)
2811 return it.get_curr();
2888 return typename GT::Node_Iterator(*
const_me());
2910 return typename GT::Arc_Iterator(*
const_me());
2933 return typename GT::Node_Arc_Iterator(p);
2982 return a->tgt_node ==
tgt;
2989 return (
typename GT::Node *) a->src_node;
3039 return a->src_node ==
src;
3046 return (
Node *) a->tgt_node;
3075 template <
class Filter>
3078 using Itor = Filter_Iterator<Node *, typename GT::Node_Arc_Iterator, Filter>;
3124 return filt.get_node(a);
3220 if (it.get_tgt_node() == tgt)
3221 return it.get_curr();
3237 DynList<Node *> ret;
3239 ret.
append(it.get_node());
3255 DynList<Node *> ret;
3257 ret.
append(it.get_node_ne());
3274 ret.
append(it.get_curr());
3290 ret.
append(it.get_curr());
3311 DynList<ArcPair> ret;
3314 auto a = it.get_curr();
3315 ret.append(std::make_tuple(a, (
Node *) a->get_connected_node(p)));
3334 DynList<ArcPair> ret;
3337 auto a = it.get_curr();
3338 ret.append(std::make_tuple(a, (
Node *) a->get_connected_node(p)));
3405 template <
class Itor,
class Operation>
3409 for (Itor it(p); it.has_curr(); it.
next_ne())
3410 if (not op(it.get_curr()))
3416 template <
class Itor,
class Operation>
3420 for (Itor it(p); it.has_curr(); it.
next_ne())
3429 return traverse_arcs<In_Iterator, Op>(p, op);
3443 for_each_arc<In_Iterator>(p, op);
3526 template <
typename T,
class Op>
3527 requires std::is_invocable_r_v<T, Op &, Arc *>
3542 template <
typename T = Arc_Type,
class Op>
3543 requires std::is_invocable_r_v<T, Op &, const T &, Arc *>
3583 return traverse_arcs<Out_Iterator>(p, op);
3597 for_each_arc<Out_Iterator>(p, op);
3652 typename GT::Arc *ret =
nullptr;
3680 template <
typename T = Arc_Type,
class Op>
3681 requires std::is_invocable_r_v<T, Op &, Arc *>
3690 template <
typename T = Arc_Type,
class Op>
3691 requires std::is_invocable_r_v<T, Op &, const T &, Arc *>
3745 template <
class Predicate>
3748 DynList<Arc*> result;
3749 for (
typename GT::Arc_Iterator it(*
const_me()); it.has_curr(); it.
next_ne())
3750 if (
pred(it.get_curr_ne()))
3751 result.
append(it.get_curr_ne());
3776 template <
class Predicate>
3807 requires(U & u) { { u.get_node_dlink() } -> std::same_as<Dlink&>; };
3811 requires(U & u) { { u.get_arc_dlink() } -> std::same_as<Dlink&>; };
3813 template <
class Compare>
3815 requires(has_node_dlink_v<GT>)
3818 mergesort(
me()->get_node_dlink(), c);
3822 template <
class Compare>
3847 template <
class Compare>
3849 requires(has_arc_dlink_v<GT>)
3852 mergesort(
me()->get_arc_dlink(), c);
3856 template <
class Compare>
3898#define ALEPH_GRAPH_COPY_MOVE_CTORS(GraphClass) \
3900 GraphClass(const GraphClass & g) \
3902 copy_graph(*this, g); \
3906 GraphClass(GraphClass && g) noexcept \
3912 GraphClass & operator=(const GraphClass & g) \
3916 copy_graph(*this, g); \
3921 GraphClass & operator=(GraphClass && g) noexcept \
3958template <
class BaseGraph>
3963 using Node =
typename BaseGraph::Node;
3964 using Arc =
typename BaseGraph::Arc;
3972 this->digraph =
true;
3984 this->digraph =
true;
3997 this->digraph =
true;
4014 this->digraph =
true;
4030 this->digraph =
true;
C++20 concepts hub: comparison, BST policy, and Aleph container concepts.
WeightedDigraph::Node Node
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
size_t size_t int32_t value
Generic directed graph (digraph) wrapper template.
Digraph(const Digraph &dg)
Copy constructor.
Digraph(Digraph &&dg) noexcept
Move constructor.
Digraph & operator=(const Digraph &g)
Copy assignment operator.
typename BaseGraph::Arc Arc
typename BaseGraph::Node Node
Digraph() noexcept
Default constructor.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
Generic filter iterator wrapper.
void next()
Advances the iterator to the next filtered element.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
void reset_first()
Resets the iterator to the first filtered element.
Node * get_first_node() const
Return any node in the graph.
Arc * get_first_arc(Node *node) const
Return any arc adjacent to a node.
virtual Node * insert_node(Node *node) noexcept
Insertion of a node already allocated.
virtual void remove_arc(Arc *arc) noexcept
Remove an arc from the graph and free it.
Graph_Node< Node_Info > Node
The graph type.
Graph_Arc< Arc_Info > Arc
The node class type.
Arc * insert_arc(Node *src_node, Node *tgt_node, void *a)
void for_each(Operation &operation)
Traverse all the container and performs an operation on each element.
Common methods for the arc of a graph.
GTArcCommon() noexcept=default
data contained in arc
ArcInfo & get_info() noexcept
Return a modifiable reference to the arc data.
void * tgt_node
Please don't use.
void * get_connected_node(void *node) noexcept
GTArcCommon(const GTArcCommon &other)
Copy constructor.
GTArcCommon(void *src, void *tgt, const ArcInfo &data)
Construct with endpoints and info (copy)
const ArcInfo & get_info() const noexcept
Return a constant reference to the arc data.
GTArcCommon(GTArcCommon &&other) noexcept
Move constructor.
Graph_Attr attrs
Please don't use.
GTArcCommon(ArcInfo &&info)
Construct from info value (move)
GTArcCommon & operator=(const GTArcCommon &other)
Copy assignment operator.
void set_state(unsigned int s) noexcept
Set the state of arc to value s
void * get_img_node(void *node) noexcept
GTArcCommon(void *src, void *tgt, ArcInfo &&data=ArcInfo())
Construct with endpoints and info (move)
unsigned int state() const noexcept
Return the state of arc.
GTArcCommon & operator=(GTArcCommon &&other) noexcept
Move assignment operator.
Common attributes and methods for nodes (vertexes) belonging to graphs.
const NodeInfo & get_info() const noexcept
Return a constant reference to the data contained in the node.
GTNodeCommon() noexcept=default
another alias for set type
GTNodeCommon & operator=(const GTNodeCommon &other)
Copy assignment operator.
GTNodeCommon(NodeInfo &&info)
Move constructor from info value.
Graph_Attr attrs
Attributes of node.
unsigned int state() const noexcept
Return the state's value.
NodeInfo & get_info() noexcept
Return a modifiable reference to the data contained in the node.
NodeInfo Node_Type
The node.
GTNodeCommon & operator=(GTNodeCommon &&other) noexcept
Move assignment operator.
GTNodeCommon(GTNodeCommon &&other) noexcept
Move constructor.
GTNodeCommon(const GTNodeCommon &other)
Copy constructor.
void set_state(unsigned int s) noexcept
Set the state to value s
size_t num_arcs
data associated to the node. Access it with get_info()
Special iterator for distinguishing input arcs of output ones.
void prev()
back to previous item.
typename Itor::Item_Type Item_Type
void next()
Advance to next arc.
Digraph_Iterator(Node *p)
Instantiate an filtered iterator for arcs on the node p
void reset_last() noexcept
Reset the iterator to last arc.
Filter_Iterator< Node *, typename GT::Node_Arc_Iterator, Filter > Itor
GT::Arc * get_curr_ne() const noexcept
GT::Arc * get_curr() const
Return the current arc.
GT::Node * get_node(typename GT::Arc *a) const noexcept
Return the node connected to p (passed during construction) and linked through a
Itor Iterator_Type
the type of items (Arc*)
auto get_current_arc() const
auto get_tgt_node_ne() const noexcept
Backward-compatible alias: return target node (same as get_node_ne()).
auto get_current_arc_ne() const noexcept
GT::Node * get_node_ne() const noexcept
Return the node connected to p (passed during construction) and linked through the current arc.
void reset_first() noexcept
Reset the iterator to first arc.
bool has_curr() const noexcept
Return true is the iterator has a current arc.
auto get_tgt_node() const
Backward-compatible alias: return target node (same as get_node()).
GT::Node * get_node() const
Common methods to the Aleph-w ( ) graph classes.
Arc * min_arc(Node *p, Compare cmp=[](Arc *a, Arc *b) { return a->get_info()< b->get_info();}) const
Find the minimum arc adjacent to a node.
void for_each_arc(Node *p, Operation &op) const
Unconditionally traverse all the arcs adjacnt to a node and on each one perform an operation.
void reset_bit_nodes(int bit) const noexcept
Reset bit to zero for all the nodes of graph.
auto out_arcs_map(Node *p, Op op) const
Return a list of outcoming arcs of a node mapped to items of type given by transformation op.
typename Arc::Arc_Type Arc_Type
auto search_in_arc(Node *p, Op &op) const
Search an incoming arc to a node satisfaying a condition.
T sum_arcs(Node *p, Extract extract) const
Sum values derived from arcs adjacent to a node.
void for_each_out_arc(Node *p, Op &op) const
Perform op on each outcoming arc of node p
auto filter_arcs(Node *p, Op &&op) const
Overload of filter_arcs(Node*, Op&) that accepts rvalues.
T foldl_arcs(Node *p, const T &init, Op op) const
Folding of arcs of a node.
bool exists_in_arc(Node *p, Op &op) const
Return true if it exists a incoming arc to p returning true for op
void for_each_arc(Node *p, Operation &&op=Operation()) const
Overload of for_each_arc(Node*, Operation&) that accepts rvalues.
void * get_cookie() const noexcept
Return a constant reference to graph's cookie.
Arc * emplace_arc(Node *src, Node *tgt, Args &&... args)
Insert a new arc in the graph by constructing its associated data in-place with the given args.
void reset_arcs() const
Reset all the arcs of graph (the control bits, the state, the counter and the cookie)
bool all_arcs(Node *p, Operation &&op=Operation()) const
Overload of all_arcs(Node*, Operation&) that accepts rvalues.
auto filter_in_arcs(Node *p, Op &&op=Op()) const
Overload of filter_in_arcs(Node*, Op&) that accepts rvalues.
void reset_cookie_arcs() const noexcept
Reset all the cookies to `nullptr for all the arcs of graph.
Container< Arc * > arcs() const
Return a container with all the arcs of the graph.
int get_bit(Arc *arc, int bit) const noexcept
Get the control bit of arc
Arc * find_arc(const Arc_Type &info) const noexcept
Find an arc mathing a content.
size_t get_num_arcs(Node *node) const noexcept
Return the total of arcs of a node.
Node * find_node(const Node_Type &info) const noexcept
Find a node mathing a content.
void for_each_arc(Operation &op) const
Unconditionally traverse all the arcs of graph and on each one perform an operation.
bool all_nodes(Operation &&op=Operation()) const
Overload of all_nodes(Operation&) that accepts rvalues.
bool exists_out_arc(Node *p, Op &op) const
Return true if it exists a outcoming arc to p returning true for op
void for_each_in_arc(Node *p, Op &op) const
Perform op on each incoming arc of node p
auto get_arc_it() const noexcept
Obtains an iterator to the arc of graph.
void reset_counter(Node *node) const noexcept
Reset the node counter to zero.
void for_each_out_arc(Node *p, Op &&op=Op()) const
Overload of for_each_out_arc(Node*, Op&) that accepts rvalues.
Node * insert_node(Node_Type &&node_info=Node_Type())
Allocate a new node, set by moving its data content and insert it into the graph.
In_Iterator get_in_it(Node *p) const noexcept
Return an input iterator on the incoming arcs to p
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)
Node * get_node() const
Return any node in the graph.
Out_Iterator get_out_it(Node *p) const noexcept
Return an output iterator on the incoming nodes to p
auto search_out_arc(Node *p, Op &op) const
Search an outcoming arc to a node satisfaying a condition.
std::tuple< Arc *, Node * > ArcPair
Pair of arc and node (topologically related)
DynList< Node * > in_nodes(Node *p) const
Return a list with the incoming nodes to p
void for_each_arc(Node *p, Operation &op) const
Perform op on each arc of node p
bool traverse_nodes(Operation &op) const
Conditioned traversal of all the nodes of a graph.
T foldl_in_arcs(Node *p, const T &init, Op op) const
Fold the incoming arcs of a node.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
Arc * search_arc(Op &&op) const
Overload of search_arc(Op&) that accepts rvalues.
bool traverse_arcs(Node *p, Operation &op) const
Conditioned traversal of all the adjacent arcs of a node.
bool traverse_in_arcs(Node *p, Op &&op=Op()) const
Overload of traverse_in_arcs(Node*, Op&) that accepts rvalues.
void reset_bit_nodes() const noexcept
Reset all the bits for all the nodes of graph.
bool exists_arc(Node *p, Operation &op) const
Determine if exists at least a arc adjacent to a node satisfying a condition.
auto search_in_arc(Node *p, Op &&op=Op()) const
Overload of search_in_arc(Node*, Op&) that accepts rvalues.
auto search_out_arc(Node *p, Op &&op=Op()) const
Overload of search_out_arc(Node*, Op&) that accepts rvalues.
void for_each_in_arc(Node *p, Op &&op=Op()) const
Overload of for_each_in_arc(Node*, Op&) that accepts rvalues.
T sum_arcs(Node *p) const
Overload of sum_arcs(Node*, Extract) using the arc info as extractor.
Arc * max_arc(Compare cmp=[](Arc *a, Arc *b) { return a->get_info()< b->get_info();}) const
Find the maximum arc in the entire graph.
Arc * insert_arc(Node *src, Node *tgt, Arc_Type &&arc_info=Arc_Type())
Create and insert a new arc linking two nodes and moving the received data.
bool none_arc(Node *p, Operation &&op) const
Overload of none_arc(Node*, Operation&) that accepts rvalues.
bool none_node(Operation &&op) const
Overload of none_node(Operation&) that accepts rvalues.
void set_bit(Node *node, int bit, int value) const noexcept
Set the control bit of node to value
DynList< Arc * > out_arcs(Node *p) const
Return a list with the outcoming arcs to p`.
bool exists_in_arc(Node *p, Op &&op=Op()) const
Overload of exists_in_arc(Node*, Op&) that accepts rvalues.
void set_bit(Arc *arc, int bit, int value) const noexcept
Set the control bit of arc to value
Arc * search_arc(Node *p, Operation &op) const
Linear search of an arc.
bool is_digraph() const noexcept
Return true if the graph this is directed.
void reset_cookie_nodes() const noexcept
Reset all the cookies to `nullptr for all the nodes of graph.
void reset_counter(Arc *arc) const noexcept
Reset the acr counter to zero.
T foldl_nodes(const T &init, Op op) const
Folding of nodes on a graph.
auto filter_arcs(Node *p, Op &op) const
Filter the arcs adjacent to a node satisfying a condition.
void set_digraph(bool val)
Temporal indication for preventing to other algorithms that an graph must be treated as a directed gr...
bool traverse_out_arcs(Node *p, Op &&op=Op()) const
Overload of traverse_out_arcs(Node*, Op&) that accepts rvalues.
bool traverse_arcs(Node *p, Operation &&op=Operation()) const
Overload of traverse_arcs(Node*, Operation&) that accepts rvalues.
bool all_arcs(Operation &op) const
Check if all the arcs of graph satisfy a boolean condition.
auto nodes_map(Op op) const
Map the nodes of a graph to a specific range.
void *& get_cookie() noexcept
Return a modifiable reference to graph's cookie.
size_t degree(Node *p) const noexcept
Return the total of arcs (or degree) of a node.
T foldl_arcs(const T &init, Op op) const
Folding of arcs on a graph.
bool all_nodes(Operation &op) const
Check if all the nodes of graph satisfy an boolean condition.
DynList< Arc * > filter_in_arcs(Node *p, Op &op) const
Filter the incoming arcs of a node.
auto arcs_map(Op operation) const
Map the arcs of a graph to a specific range.
bool all_in_arcs(Node *p, Op &op) const
Return true if op is true for all the incoming arcs to node p
void reset_bit_arcs() const noexcept
Reset all the bits for all the arcs of graph.
static void map_arcs(A1 *p, A2 *q) noexcept
Map the arcs through their cookies.
auto in_pairs(Node *p) const
Return a list of pair incoming arcs and nodes.
void reset_counter_nodes() const noexcept
Reset all the counters to zero for all the nodes of graph.
Arc * search_arc(Node *src, Node *tgt) const noexcept
Search an arc linking two nodes.
bool traverse_in_arcs(Node *p, Op &op) const
Traverse the incoming arcs of node p executing the conditioned operation
typename Node::Node_Type Node_Type
size_t count_arcs(Node *p, Operation op=[](Arc *) { return true;}) const
Count arcs adjacent to a node satisfying a condition.
auto arcs_map(Node *p, Op operation) const
Map the adjacent arcs of a node to a specific range.
void sort_arcs(Compare &cmp) noexcept
Sort all the arcs of the graph according to a specific criteria.
DynList< Arc * > in_arcs(Node *p) const
Return a list with the incoming arcs to p`.
Node * get_connected_node(Arc *arc, Node *node) const noexcept
Return the adjacent node to node through arc.
bool traverse_out_arcs(Node *p, Op &op) const
Traverse the outcoming arcs of node p executing the conditioned operation
void common_swap(GT &g) noexcept
std::pair< DynList< Node * >, DynList< Node * > > partition_nodes(Operation op) const
Partition nodes into two groups based on a predicate.
constexpr bool is_empty() const noexcept
Checks if the graph is empty (has no nodes).
bool exists_arc(Operation &&op=Operation()) const
Overload of exists_arc(Operation&) that accepts rvalues.
long & get_counter(Node *node) const noexcept
Get a modifiable reference to the counter of node
bool traverse_arcs(Node *p, Operation &op) const
Traverse of arcs of a node according to specific arcs iterator.
bool all_out_arcs(Node *p, Op &op) const
Return true if op is true for all the outcoming arcs to node p
void reset_bit(Node *node, int bit) const noexcept
Reset the bit of node (to zero)
auto filter_nodes(Op &&op) const
Overload of filter_nodes(Op&) that accepts rvalues.
void reset_bit_arcs(int bit) const noexcept
Reset bit to zero for all the arcs of graph.
size_t out_degree(Node *p) const noexcept
Compute the output degree of a node.
Node * emplace_node(Args &&... args)
Insert a new node in the graph by constructing it in-place with the given args.
Arc * insert_arc(Node *src, Node *tgt, const Arc_Type &arc_info)
Create and insert a new arc linking two nodes and copying data.
void for_each_node(Operation &operation) const
Unconditionally traverse all the nodes of graph and on each one perform an operation.
void reset_node_counters() const noexcept
Reset all the node counters of graph to zero.
Arc * max_arc(Node *p, Compare cmp=[](Arc *a, Arc *b) { return a->get_info()< b->get_info();}) const
Find the maximum arc adjacent to a node.
bool none_node(Operation &op) const
Determine if no node satisfies a condition.
bool traverse_nodes(Operation &&op=Operation()) const
Overload of traverse_nodes(Operation&) that accepts rvalues.
Bit_Fields & get_control_bits(Node *node) const noexcept
Return a reference to control fields of node
Node * get_arc(Node *p)
Return any arc adjacent to a node.
constexpr size_t get_num_arcs() const noexcept
Arc * search_arc(Op &op) const
Linear search of an arc.
void reset_counter_arcs() const noexcept
Reset all the counters to zero for all the arcs of graph.
void sort_arcs(Compare &&cmp=Compare()) noexcept
constexpr size_t vsize() const noexcept
void reset_bits(Node *node) const noexcept
Reset all the control bits of node
bool all_out_arcs(Node *p, Op &&op=Op()) const
Overload of all_out_arcs(Node*, Op&) that accepts rvalues.
Arc * search_directed_arc(Node *src, Node *tgt) const noexcept
Search a directed arc linking two nodes.
long & get_counter(Arc *arc) const noexcept
Get a modifiable reference to the counter of arc
bool traverse_arcs(Operation &&op=Operation()) const
Overload of traverse_arcs(Operation&) that accepts rvalues.
bool all_arcs(Node *p, Operation &op) const
Check if all the arcs adjacent to a node satisfy an boolean condition.
const GT * const_me() const
size_t esize() const noexcept
Return the total of arcs of graph.
void reset_arc(Arc *arc) const noexcept
Reset all the control attributes of arc.
void reset_nodes() const
Reset all the nodes of graph (the control bits, the state, the counter and the cookie)
void reset_node(Node *p) const noexcept
Reset all the control attributes of node p.
auto in_arcs_map(Node *p, Op op) const
Return a list of incoming arcs of a node mapped to items of type given by transformation op.
size_t in_degree(Node *p) const noexcept
Compute the input degree of a node.
auto filter_arcs(Op &op) const
Filter the arcs of graph satisfying a condition.
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
Arc * search_arc(Node *p, Operation &&op=Operation()) const
Overload of search_arc(Node*, Operation&) that accepts rvalues.
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
Node * get_arc() const
Return any arc in the graph.
auto filter_out_arcs(Node *p, Op &&op=Op()) const
Overload of filter_out_arcs(Node*, Op&) that accepts rvalues.
DynList< Arc * > collect_arcs_if(Predicate pred) const
Collect all arcs matching a predicate.
void for_each_arc(Operation &&operation=Operation()) const
Overload of for_each_arc(Operation&) that accepts rvalues.
bool all_in_arcs(Node *p, Op &&op=Op()) const
Overload of all_in_arcs(Node*, Op&) that accepts rvalues.
void reset_bits(Arc *arc) const noexcept
Reset all the control bits of arc
bool exists_node(Operation &op) const
Determine if exists at least a node satisfying a condition.
auto get_arc_it(Node *p) const noexcept
Obtains an iterator to the adjacent arcs of a node.
DynList< Node * > out_nodes(Node *p) const
Return a list with the outcoming nodes to p
void *& get_cookie(Arc *arc) const noexcept
Get a modifiable reference to the cookie pointer of arc
Container< Node * > nodes() const
Return a container with all the nodes of the graph.
static void map_nodes(N1 *p, N2 *q) noexcept
Map the nodes through their cookies.
std::pair< DynList< Arc * >, DynList< Arc * > > partition_arcs(Operation op) const
Partition arcs into two groups based on a predicate.
Container< Arc * > arcs(Node *p) const
Return a container with all the arcs adjacent to a node.
void reset_arc_counters() const noexcept
Reset all the arc counters of graph to zero.
void reset_bit(Arc *arc, int bit) const noexcept
Reset the bit of arc to zero.
void sort_nodes(Compare &cmp) noexcept
auto filter_nodes(Op &op) const
Filter the nodes satisfying a condition.
bool all_arcs(Operation &&op=Operation()) const
Overload of all_arcs(Operation&) that accepts rvalues.
Node * search_node(Op &op) const
Linear search of a node.
Node * search_node(Op &&op) const
Overload of search_node(Op&) that accepts rvalues.
Bit_Fields & get_control_bits(Arc *arc) const noexcept
Return a reference to the control bits of arc
DynList< Arc * > filter_out_arcs(Node *p, Op &op) const
Filter the outcoming arcs of a node.
void sort_nodes(Compare &&cmp=Compare()) noexcept
bool traverse_arcs(Operation &op) const
Conditioned traversal of all the arcs of a graph.
DynList< Node * > adjacent_nodes(Node *p) const
Get all adjacent nodes (neighbors) of a node.
bool none_arc(Operation &&op) const
Overload of none_arc(Operation&) that accepts rvalues.
auto filter_arcs(Op &&op) const
Overload of filter_arcs(Op&) that accepts rvalues.
static constexpr bool has_arc_dlink_v
void remove_arcs_if(Predicate pred)
Remove all arcs matching a predicate.
bool none_arc(Node *p, Operation &op) const
Determine if no arc adjacent to a node satisfies a condition.
void *& get_cookie(Node *node) const noexcept
Get a modifiable reference to the cookie pointer of node
bool exists_node(Operation &&op=Operation()) const
Overload of exists_node(Operation&) that accepts rvalues.
size_t count_arcs(Operation op=[](Arc *) { return true;}) const
Count the arcs satisfying a condition.
void for_each_node(Operation &&operation=Operation()) const
Overload of for_each_node(Operation&) that accepts rvalues.
T foldl_out_arcs(Node *p, const T &init, Op op) const
Fold-left over outcoming arcs of a node.
Arc * min_arc(Compare cmp=[](Arc *a, Arc *b) { return a->get_info()< b->get_info();}) const
Find the minimum arc in the entire graph.
bool exists_out_arc(Node *p, Op &&op=Op()) const
Overload of exists_out_arc(Node*, Op&) that accepts rvalues.
static constexpr bool has_node_dlink_v
Sort all the nodes of the graph according to a specific criteria.
auto out_pairs(Node *p) const
Return a list of pair outcoming arcs and nodes.
int get_bit(Node *node, int bit) const noexcept
Get the control bit of node
bool none_arc(Operation &op) const
Determine if no arc satisfies a condition.
bool exists_arc(Node *p, Operation &&op=Operation()) const
Overload of exists_arc(Node*, Operation&) that accepts rvalues.
bool exists_arc(Operation &op) const
Determine if exists at least a arc satisfying a condition.
size_t count_nodes(Operation op=[](Node *) { return true;}) const
Count the nodes satisfying a condition.
f(args...) is a valid call expression, exactly as written.
f(args...) is a valid call whose result is usable as a condition.
Concept for basic graph iterators.
Concept for graph arc iterators.
Concept for graph node iterators.
Concept for node adjacency iterators.
Concept for resettable graph iterators.
int cmp(const __gmp_expr< T, U > &expr1, const __gmp_expr< V, W > &expr2)
#define ARC_COOKIE(p)
Return the arc cookie
#define NODE_COUNTER(p)
Get the counter of a node.
#define ARC_COUNTER(p)
Return the counter of arc p.
#define ARC_BITS(p)
Return the control bits of arc p.
#define NODE_COOKIE(p)
Return the node cookie
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
#define NODE_BITS(p)
Get the control bits of a node.
void copy_graph(GT >gt, const GT &gsrc, bool cookie_map=false)
Explicit copy of graph.
Freq_Node * pred
Predecessor node in level-order traversal.
Main namespace for Aleph-w library functions.
T & swap(T &t1, T &t2)
Generic swap using object's swap method.
std::decay_t< typename HeadC::Item_Type > T
auto get_curr() const
Return the current tuple (bounds-checked).
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
Empty placeholder class with no data members.
What GT::Arc_Iterator::get_curr() yields, deferred on D.
decltype(std::declval< typename concepts_detail::defer< GT, D >::type::Arc_Iterator & >().get_curr()) type
What GT::Node_Arc_Iterator::get_curr() yields, deferred on D.
decltype(std::declval< typename concepts_detail::defer< GT, D >::type::Node_Arc_Iterator & >().get_curr()) type
What GT::Node_Iterator::get_curr() yields, deferred on D.
decltype(std::declval< typename concepts_detail::defer< GT, D >::type::Node_Iterator & >().get_curr()) type
Used internally for some graphs for compare their arcs.
Cmp_Dlink_Arc(Cmp &__cmp) noexcept
bool operator()(Dlink *d1, Dlink *d2) const noexcept
Cmp_Dlink_Arc(Cmp &&__cmp=Cmp()) noexcept
Used internally for some graphs for compare their nodes.
Cmp_Dlink_Node(Cmp &__cmp) noexcept
bool operator()(Dlink *d1, Dlink *d2) const noexcept
Cmp_Dlink_Node(Cmp &&__cmp=Cmp()) noexcept
Common arc iterator for graph having its arcs derived from Dlink class.
Arc * get_curr() const
Return current arc.
Arc * Item_Type
The type of item that returns the iterator.
Arc * get_curr_ne() const noexcept
Return current arc without exception.
Node * get_tgt_node() const
Return the target node of current arc (if it is a directed graph)
Arc * get_current_arc() const
Return the current arc.
Node * get_src_node_ne() const noexcept
Return the source node of current arc (if it is a directed graph)
Arc * get_current_arc_ne() const noexcept
Return the current arc without exception.
Node * get_tgt_node_ne() const noexcept
Return the target node of current arc (if it is a directed graph)
Node * get_src_node() const
Return the source node of current arc (if it is a directed graph)
GTArcIterator(Dlink &head) noexcept
Build a iterator for all the arcs of g.
Common node iterator for graph having its node derived from Dlink class.
GTNodeIterator() noexcept
Node * Item_Type
The type of item that returns the iterator.
Node * get_current_node() const
Return the current node.
GTNodeIterator(Dlink &head) noexcept
Build a iterator for all the nodes of g.
Node * get_curr_ne() const noexcept
Return the current node without exception.
Node * get_current_node_ne() const
Node * get_curr() const
Return the current node.
Filter for input arcs of a node.
Node * get_node(Arc *a) const noexcept
Return the source node of arc a
In_Filt(Node *__tgt=nullptr) noexcept
target node of iteration
bool operator()(Arc *a) const noexcept
Return true if the arc a is incoming arc to tgt; false otherwise.
Alias for Digraph_Iterator
Filter for output arcs of a node.
Out_Filt(Node *__src) noexcept
source node of iteration
Node * get_node(Arc *a) const noexcept
Return the source node of arc a (whose target is tgt)
bool operator()(Arc *a) const noexcept
Return true if a is a outcoming arc from src; false otherwise.