|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Determines whether a graph contains cycles. More...
#include <tpl_test_acyclique.H>
Public Member Functions | |
| Has_Cycle (SA &&__sa=SA()) | |
| Has_Cycle (SA &__sa) | |
| bool | operator() (GT &g) const |
| Invokes the cycle-existence test. | |
| bool | operator() (GT &g, size_t num_arcs) const |
| Invokes the cycle-existence test. | |
Private Attributes | |
| SA & | sa |
Determines whether a graph contains cycles.
Has_Cycle performs a depth-first search on graph g, starting from a node, and checks whether the graph contains a cycle.
The class takes two template parameters:
The class uses the Test_Cycle bit and resets it at the beginning of the algorithm to mark already visited nodes and arcs.
Definition at line 190 of file tpl_test_acyclique.H.
|
inline |
Definition at line 195 of file tpl_test_acyclique.H.
|
inline |
Definition at line 199 of file tpl_test_acyclique.H.
|
inline |
Invokes the cycle-existence test.
If g is an undirected graph (not a digraph), then the algorithm compares the number of arcs with the number of nodes. If the graph has as many arcs as nodes (or more), then it is concluded that the graph contains cycles. Consequently, this technique does not work for multigraphs.
| [in] | g | the graph to test. |
Definition at line 218 of file tpl_test_acyclique.H.
References Aleph::maps(), and Aleph::Has_Cycle< GT, SA >::sa.
|
inline |
Invokes the cycle-existence test.
If g is an undirected graph (not a digraph), then the algorithm compares the number of arcs with the number of nodes. If the graph has as many arcs as nodes (or more), then it is concluded that the graph contains cycles. Consequently, this technique does not work for multigraphs.
| [in] | g | the graph to test. |
| [in] | num_arcs | number of arcs in the graph (for optimization). |
Definition at line 239 of file tpl_test_acyclique.H.
References Aleph::maps(), and Aleph::Has_Cycle< GT, SA >::sa.
Definition at line 192 of file tpl_test_acyclique.H.
Referenced by Aleph::Has_Cycle< GT, SA >::operator()(), and Aleph::Has_Cycle< GT, SA >::operator()().