Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::Compute_Cycle_In_Digraph< GT, Itor, SA > Class Template Reference

Determines if a digraph contains a cycle and constructs it. More...

#include <Tarjan.H>

Public Member Functions

 Compute_Cycle_In_Digraph (SA __sa=SA())
 Constructs a cycle computation instance with an arc filter.
 
bool operator() (const GT &g, Path< GT > &path) const
 Invokes the computation of a cycle in a digraph.
 
Path< GToperator() (const GT &g) const
 Computes and returns a cycle in the digraph.
 
Path< GToperator() (const GT &g, typename GT::Node *src) const
 Computes and returns a cycle starting from a specific node.
 

Private Attributes

SA sa
 

Detailed Description

template<class GT, template< typename, class > class Itor = Out_Iterator, class SA = Dft_Show_Arc<GT>>
class Aleph::Compute_Cycle_In_Digraph< GT, Itor, SA >

Determines if a digraph contains a cycle and constructs it.

Compute_Cycle_In_Digraph() takes a digraph g, determines if it contains a cycle, and if so, constructs a path containing the cycle in question.

The class is based on Tarjan's algorithm.

The function uses two type parameters:

  1. GT: the digraph class.
  2. SA: the arc filter used by the internal iterator.

The class uses the build_subtree bit to mark visited nodes and arcs.

Note
This class is intended for directed graphs. Behavior on undirected graphs is undefined.

Definition at line 1020 of file Tarjan.H.

Constructor & Destructor Documentation

◆ Compute_Cycle_In_Digraph()

template<class GT , template< typename, class > class Itor = Out_Iterator, class SA = Dft_Show_Arc<GT>>
Aleph::Compute_Cycle_In_Digraph< GT, Itor, SA >::Compute_Cycle_In_Digraph ( SA  __sa = SA())
inline

Constructs a cycle computation instance with an arc filter.

Parameters
[in]__saArc filter functor. Defaults to Dft_Show_Arc<GT>.

Definition at line 1030 of file Tarjan.H.

Member Function Documentation

◆ operator()() [1/3]

template<class GT , template< typename, class > class Itor = Out_Iterator, class SA = Dft_Show_Arc<GT>>
Path< GT > Aleph::Compute_Cycle_In_Digraph< GT, Itor, SA >::operator() ( const GT g) const
inline

Computes and returns a cycle in the digraph.

Parameters
[in]gThe graph to search for cycles.
Returns
A Path containing the cycle if found, empty path otherwise.
Exceptions
bad_allocif there is not enough memory.

Definition at line 1056 of file Tarjan.H.

References Aleph::maps(), and Aleph::Compute_Cycle_In_Digraph< GT, Itor, SA >::sa.

◆ operator()() [2/3]

template<class GT , template< typename, class > class Itor = Out_Iterator, class SA = Dft_Show_Arc<GT>>
bool Aleph::Compute_Cycle_In_Digraph< GT, Itor, SA >::operator() ( const GT g,
Path< GT > &  path 
) const
inline

Invokes the computation of a cycle in a digraph.

Parameters
[in]gthe graph on which to compute its blocks.
[out]pathpath that defines the cycle.
Returns
true if the graph contains a cycle; false otherwise. In the latter case the value of path is indeterminate.
Exceptions
bad_allocif there is not enough memory.

Definition at line 1043 of file Tarjan.H.

References Aleph::maps(), and Aleph::Compute_Cycle_In_Digraph< GT, Itor, SA >::sa.

◆ operator()() [3/3]

template<class GT , template< typename, class > class Itor = Out_Iterator, class SA = Dft_Show_Arc<GT>>
Path< GT > Aleph::Compute_Cycle_In_Digraph< GT, Itor, SA >::operator() ( const GT g,
typename GT::Node src 
) const
inline

Computes and returns a cycle starting from a specific node.

Parameters
[in]gThe graph to search for cycles.
[in]srcThe source node to start the search from (must not be null).
Returns
A Path containing the cycle if found, empty path otherwise.
Exceptions
domain_errorif src is null.
bad_allocif there is not enough memory.

Definition at line 1071 of file Tarjan.H.

References Aleph::Tarjan_Connected_Components< GT, Itor, SA >::compute_cycle(), Aleph::maps(), and Aleph::Compute_Cycle_In_Digraph< GT, Itor, SA >::sa.

Member Data Documentation

◆ sa


The documentation for this class was generated from the following file: