52#ifndef TOPOLOGICAL_SORT_H
53#define TOPOLOGICAL_SORT_H
102 template <
template <
class>
class List>
138 template <
template <
class>
class List>
151 auto curr = it.get_current_node_ne();
224 template <
template <
class>
class List>
237 for (
auto it = g.
get_node_it(); it.has_curr(); it.next_ne())
239 auto p = it.get_current_node_ne();
255 auto tgt = it.get_tgt_node_ne();
288 for (
typename GT::Node_Iterator i(g); i.has_curr(); i.next_ne())
290 j.has_curr(); j.next_ne())
295 for (
typename GT::Node_Iterator it(g); it.has_curr(); it.next_ne())
297 auto p = it.get_current_node_ne();
316 auto tgt = it.get_tgt_node_ne();
322 ranks.append(std::move(rank));
336 auto result = this->
ranks<>(g);
338 for (
auto it = result.get_it(); it.has_curr(); it.next_ne())
339 list.append(std::move(it.get_curr()));
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.
Dynamic singly linked list with functional programming support.
DynList & swap(DynList &l) noexcept
Swap this with l.
void next_ne() noexcept
Advances the iterator to the next filtered element (noexcept version).
constexpr bool is_empty() const noexcept
Return true if list is empty.
size_t size() const noexcept
Count the number of elements of the list.
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.
List_Graph< Graph_Node< int >, Graph_Arc< int > > GT
#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_BITS(p)
Get the control bits of a node.
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 filter for filtered iterators on arcs.
Dynamic queue implementation based on linked lists.
Generic graph and digraph implementations.