52#ifndef TOPOLOGICAL_SORT_H
53#define TOPOLOGICAL_SORT_H
77template <AlephGraph
GT,
104 template <
template <
class>
class List>
118 for (
Itor<GT,SA> it(curr,
sa); it.has_curr()
and list.size() < n; it.next_ne())
140 template <
template <
class>
class List>
150 for (
auto it = g.
get_node_it(); it.has_curr()
and list.size() < n;
153 auto curr = it.get_current_node_ne();
190template <AlephGraph
GT,
226 template <
template <
class>
class List>
239 for (
auto it = g.
get_node_it(); it.has_curr(); it.next_ne())
241 auto p = it.get_current_node_ne();
257 auto tgt = it.get_tgt_node_ne();
290 for (
typename GT::Node_Iterator i(g); i.has_curr(); i.next_ne())
292 j.has_curr(); j.next_ne())
297 for (
typename GT::Node_Iterator it(g); it.has_curr(); it.next_ne())
299 auto p = it.get_current_node_ne();
318 auto tgt = it.get_tgt_node_ne();
324 ranks.append(std::move(rank));
338 auto result = this->
ranks<>(g);
340 for (
auto it = result.get_it(); it.has_curr(); it.next_ne())
341 list.append(std::move(it.get_curr()));
C++20 concepts for the protocol shared by graph algorithms.
List_Graph< Graph_Node< Node_Info >, Graph_Arc< Arc_Info > > GT
void append(Dlink *node) noexcept
Insert node before this.
void insert(Dlink *node) noexcept
Insert node after this.
Node belonging to a double circular linked list with header node.
Dynamic doubly linked list with O(1) size and bidirectional access.
Dynamic queue of elements of generic type T based on single linked list.
T & put(const T &data)
The type of element.
T get()
Remove the oldest item of the queue.
void swap(DynListQueue &__q) noexcept
Swap this with __q in constant time.
bool is_empty() const noexcept
Return true if this is empty.
Doubly-linked list (defined in tpl_dynList.H).
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
Filtered iterator for outcoming arcs of a node.
Computes topological ordering using breadth-first search (Kahn's algorithm).
void operator()(const GT &g, DynList< DynList< typename GT::Node * > > &list)
Operator() overload returning ranks as DynList of DynList.
Q_Topological_Sort(SA &&__sa=SA())
Constructor with rvalue arc filter.
Q_Topological_Sort(SA &__sa)
Constructor with lvalue arc filter.
void operator()(const GT &g, DynDlist< typename GT::Node * > &list)
Operator() overload for backward compatibility (flat list).
void operator()(const GT &g, DynDlist< DynList< typename GT::Node * > > &list)
Operator() overload returning ranks as DynDlist of DynList.
List< typename GT::Node * > perform(const GT &g)
Compute topological ordering using BFS (Kahn's algorithm).
RankList< List< typename GT::Node * > > ranks(const GT &g)
Compute rank-based topological ordering.
Computes topological ordering using depth-first search.
void topological_sort(typename GT::Node *curr, List< typename GT::Node * > &list)
Recursive helper for DFS-based topological sort.
List< typename GT::Node * > perform(const GT &g)
Compute topological ordering using DFS.
Topological_Sort(SA &&__sa=SA())
Constructor with rvalue arc filter.
void operator()(const GT &g, DynDlist< typename GT::Node * > &list)
Operator() overload for backward compatibility.
Topological_Sort(SA &__sa)
Constructor with lvalue arc filter.
void reset_bit_nodes(int bit) const noexcept
Reset bit to zero for all the nodes of graph.
constexpr size_t get_num_nodes() const noexcept
Return the total of nodes of graph.
void reset_counter_nodes() const noexcept
Reset all the counters to zero for all the nodes of graph.
auto get_node_it() const noexcept
Obtains an iterator to the nodes of graph.
#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.
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.
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
Filtered iterator on all the arcs of a graph.
Default filter for filtered iterators on arcs.
Dynamic queue implementation based on linked lists.
Generic graph and digraph implementations.