177 mutable size_t n_ = 0;
282 const long result =
low<GT>(v);
292 auto q =
blk.insert_node(p->get_info());
459 auto a = block.get_first_arc();
460 auto start = block.get_tgt_node(a);
461 auto end = block.get_src_node(a);
471 path_ptr_->append_directed(table.
find(i.get_current_node_ne()));
525 auto q =
blk.insert_node();
533 if (
blk.get_num_nodes() == 1)
537 for (
typename GT::Node_Iterator j(
blk); j.has_curr(); j.next_ne())
539 auto bsrc = j.get_curr();
545 auto ga =
k.get_curr();
551 auto ta =
blk.insert_arc(
bsrc, ptr->second);
626 for (
typename GT::Node_Iterator it(g);
df_count_ <
n_; it.next_ne())
635 GT &
blk = i.get_curr();
636 for (
typename GT::Node_Iterator j(
blk); j.has_curr(); j.next_ne())
638 auto bsrc = j.get_curr();
644 auto ga =
k.get_curr();
687 for (
typename GT::Node_Iterator it(g);
df_count_ <
n_; it.next_ne())
732 for (
typename GT::Node_Iterator it(g);
df_count_ <
n_; it.next_ne())
785 GT &curr = it.get_curr();
791 arc_list.
append(it.get_curr());
811 auto &
blk = it.get_curr();
812 while (
not blk.is_empty())
831 for (
typename GT::Node_Iterator it(g);
df_count_ <
n_; it.next_ne())
873 for (
typename GT::Node_Iterator it(g);
df_count_ <
n_; it.next_ne())
925 for (
typename GT::Node_Iterator it(g);
df_count_ <
n_; it.next_ne())
1025 return tarjan.compute_cycle(g, path);
Exception handling system with formatted messages for Aleph-w.
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
C++20 concepts for the protocol shared by graph algorithms.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
Determines if a digraph contains a cycle and constructs it.
bool operator()(const GT &g, Path< GT > &path) const
Invokes the computation of a cycle in a digraph.
Compute_Cycle_In_Digraph(SA __sa=SA())
Constructs a cycle computation instance with an arc filter.
bool has_curr() const noexcept
Return true if the iterator has current item.
Dynamic doubly linked list with O(1) size and bidirectional access.
T & append(const T &item)
Append a copied item at the end of the list.
Dynamic stack of elements of generic type T based on a singly linked list.
bool is_empty() const noexcept
Check if the stack is empty.
T pop()
Remove and return the top item of the stack.
T & push(const T &data)
Push an item by copy onto the top of the stack.
void empty() noexcept
Remove all elements from the stack.
Iterator on the items of list.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
Dynamic map implemented with an AVL tree.
Pair * search(const Key &key) const noexcept
Collect all keys.
Pair * insert(const Key &key, const Data &data)
Insert a key-value pair.
Data & find(const Key &key)
Find the value associated with key.
bool has_curr() const noexcept
size_t size() const noexcept
Count the number of elements of the list.
void swap(List_Graph &g) noexcept
Swap in constant time this with g
Filtered iterator for outcoming arcs of a node.
Iterator on nodes and arcs of a path.
void empty()
Clean the path: all the nodes and arc are removed.
void set_graph(const GT &__g, Node *start_node=nullptr)
Set the graph of the path.
Computes strongly connected components (SCCs) in a directed graph using Tarjan's algorithm.
void init_tarjan(const GT &g)
Initialize internal state for a Tarjan traversal.
bool has_computation() const noexcept
Check if a computation has been performed.
SA & get_filter() noexcept
Returns the arc filter used by this instance.
DynList< DynList< typename GT::Node * > > connected_components(const GT &g)
Tarjan_Connected_Components(const Tarjan_Connected_Components &)=delete
Tarjan instances should not be copied (they hold internal traversal state)
void init_node_and_push_in_stack(typename GT::Node *p)
Initialize a node and push it onto the traversal stack.
bool build_cycle(typename GT::Node *v)
Recursive DFS to find and construct a cycle starting from v.
Tarjan_Connected_Components & operator=(const Tarjan_Connected_Components &)=delete
void connected_components(const GT &g, DynList< DynList< typename GT::Node * > > &blks)
Computes the strongly connected components (SCCs) of a digraph.
bool test_connectivity(const GT &g)
Tests whether the digraph is strongly connected.
bool has_cycle(typename GT::Node *v)
Recursive DFS to detect if a cycle exists starting from v.
void connected_components(const GT &g, DynList< GT > &blk_list, DynList< typename GT::Arc * > &arc_list)
Computes the strongly connected components (SCCs) of a digraph.
bool compute_cycle(const GT &g, typename GT::Node *src, Path< GT > &path)
Finds and constructs a cycle starting from a specific node, if one exists.
long scc_by_blocks(typename GT::Node *v, DynList< GT > &blk_list)
Recursive DFS to find SCCs and build mapped subgraphs.
void scc_by_lists(typename GT::Node *v, DynList< DynList< typename GT::Node * > > &blks)
Recursive DFS to find SCCs and collect nodes into lists.
bool compute_cycle(const GT &g, Path< GT > &path)
Finds and constructs a cycle in the digraph, if one exists.
void build_path(const GT &block, DynMapAvlTree< typename GT::Node *, typename GT::Node * > &table)
Build a cycle path from a strongly connected block.
GT * get_graph() const noexcept
Get the graph of the last computation.
const SA & get_filter() const noexcept
Returns the arc filter used by this instance (const version).
bool has_cycle(const GT &g)
Determines whether the digraph contains at least one cycle.
Tarjan_Connected_Components(Tarjan_Connected_Components &&)=default
Move is allowed.
bool is_dag(const GT &g)
Determines whether the directed graph is acyclic (a DAG).
Tarjan_Connected_Components(SA __sa=SA()) noexcept
Constructs a Tarjan algorithm instance for computing strongly connected components.
void scc_by_len(typename GT::Node *v, DynList< size_t > &sizes)
Recursive DFS to find SCCs and count their sizes.
DynListStack< typename GT::Node * > stack_
GT::Node * pop_from_stack()
Pop a node from the traversal stack.
static bool is_node_in_stack(typename GT::Node *p) noexcept
Check if a node is currently on the traversal stack.
void connected_components(const GT &g, DynList< size_t > &blks)
Computes the sizes of the strongly connected components (SCCs).
void operator()(const GT &g, DynList< GT > &blk_list, DynList< typename GT::Arc * > &arc_list)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool is_connected(typename GT::Node *v)
Recursive DFS to test if the graph is strongly connected.
size_t num_connected_components(const GT &g)
Returns the number of strongly connected components in the graph.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
static void map_arcs(A1 *p, A2 *q) noexcept
Map the arcs through their cookies.
Node * get_tgt_node(Arc *arc) const noexcept
Return the target node of arc (only for directed graphs)
static void map_nodes(N1 *p, N2 *q) noexcept
Map the nodes through their cookies.
#define NODE_COUNTER(p)
Get the counter of a node.
#define IS_NODE_VISITED(p, bit)
Determine whether the control bit is set or not to one.
#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.
Singly linked list implementations with head-tail access.
Main namespace for Aleph-w library functions.
Itor::difference_type count(const Itor &beg, const Itor &end, const T &value)
Count elements equal to a value.
Default filter for filtered iterators on arcs.
Functor to initialize node metadata for Tarjan traversal.
void operator()(const GT &g, typename GT::Node *p) const noexcept
Dynamic stack implementation based on linked lists.
Dynamic set implementations based on balanced binary search trees.
Path finding algorithms in graphs.
Utility algorithms and operations for graphs.