|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Computes topological ordering using breadth-first search (Kahn's algorithm). More...
#include <topological_sort.H>
Public Member Functions | |
| Q_Topological_Sort (SA &&__sa=SA()) | |
| Constructor with rvalue arc filter. | |
| Q_Topological_Sort (SA &__sa) | |
| Constructor with lvalue arc filter. | |
| template<template< class > class List> | |
| List< typename GT::Node * > | perform (const GT &g) |
| Compute topological ordering using BFS (Kahn's algorithm). | |
| template<template< class > class RankList = DynList, template< class > class List = DynList> | |
| RankList< List< typename GT::Node * > > | ranks (const GT &g) |
| Compute rank-based topological ordering. | |
| void | operator() (const GT &g, DynDlist< DynList< typename GT::Node * > > &list) |
| Operator() overload returning ranks as DynDlist of DynList. | |
| void | operator() (const GT &g, DynList< DynList< typename GT::Node * > > &list) |
| Operator() overload returning ranks as DynList of DynList. | |
| void | operator() (const GT &g, DynDlist< typename GT::Node * > &list) |
| Operator() overload for backward compatibility (flat list). | |
Private Attributes | |
| SA & | sa |
Computes topological ordering using breadth-first search (Kahn's algorithm).
This class performs topological sorting using a queue-based approach. It repeatedly:
Also provides rank-based ordering where nodes at the same "level" (same topological depth) are grouped together, useful for identifying parallelizable tasks.
| GT | The directed graph type. |
| Itor | Iterator type for traversing outgoing arcs (default: Out_Iterator). |
| SA | Arc filter/selector (default: Dft_Show_Arc<GT>). |
Definition at line 191 of file topological_sort.H.
|
inline |
Constructor with rvalue arc filter.
| __sa | Arc filter/selector (moved). |
Definition at line 200 of file topological_sort.H.
|
inline |
Constructor with lvalue arc filter.
| __sa | Arc filter/selector (referenced). |
Definition at line 206 of file topological_sort.H.
|
inline |
Operator() overload returning ranks as DynDlist of DynList.
| g | The directed acyclic graph. |
| list | Output list to receive the rank-based ordering. |
Definition at line 334 of file topological_sort.H.
References Aleph::maps().
|
inline |
Operator() overload for backward compatibility (flat list).
| g | The directed acyclic graph. |
| list | Output list to receive the topological ordering. |
Definition at line 355 of file topological_sort.H.
References Aleph::maps(), and Aleph::DynList< T >::swap().
|
inline |
Operator() overload returning ranks as DynList of DynList.
| g | The directed acyclic graph. |
| list | Output list to receive the rank-based ordering. |
Definition at line 346 of file topological_sort.H.
References Aleph::maps(), and Aleph::DynList< T >::swap().
|
inline |
Compute topological ordering using BFS (Kahn's algorithm).
Uses in-degree counting and a queue to process source nodes, producing a valid topological ordering.
| g | The directed acyclic graph. |
| std::bad_alloc | If memory allocation fails. |
| std::domain_error | If g is not a digraph. |
Definition at line 225 of file topological_sort.H.
References Aleph::DynListQueue< T >::get(), GraphCommon< GT, Node, Arc >::get_node_it(), Aleph::DynListQueue< T >::is_empty(), Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_COUNTER, Aleph::DynListQueue< T >::put(), GraphCommon< GT, Node, Arc >::reset_counter_nodes(), and Aleph::Q_Topological_Sort< GT, Itor, SA >::sa.
|
inline |
Compute rank-based topological ordering.
Returns the topological ordering organized by ranks (levels). Each rank contains nodes that can be processed in parallel, as they have no dependencies on each other within the same rank.
| RankList | Outer container type for ranks (default: DynList). |
| List | Inner container type for nodes in each rank (default: DynList). |
| g | The directed acyclic graph. |
| std::bad_alloc | If memory allocation fails. |
| std::domain_error | If g is not a digraph. |
Definition at line 283 of file topological_sort.H.
References Aleph::DynListQueue< T >::get(), Aleph::HTList::is_empty(), Aleph::DynListQueue< T >::is_empty(), Aleph::maps(), NODE_COUNTER, Aleph::DynListQueue< T >::put(), Aleph::DynList< T >::put(), Aleph::Q_Topological_Sort< GT, Itor, SA >::ranks(), GraphCommon< GT, Node, Arc >::reset_counter_nodes(), Aleph::Q_Topological_Sort< GT, Itor, SA >::sa, and Aleph::DynListQueue< T >::swap().
Referenced by Aleph::Q_Topological_Sort< GT, Itor, SA >::ranks().
|
private |
Definition at line 193 of file topological_sort.H.
Referenced by Aleph::Q_Topological_Sort< GT, Itor, SA >::perform(), and Aleph::Q_Topological_Sort< GT, Itor, SA >::ranks().