|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Determines whether a graph is acyclic (contains no cycles). More...
#include <tpl_test_acyclique.H>
Public Member Functions | |
| Is_Graph_Acyclique (SA &&__sa=SA()) | |
| Is_Graph_Acyclique (SA &__sa) | |
| bool | operator() (GT &g, size_t num_arcs) |
| Invokes the acyclicity test, with the number of arcs that the filter shows. | |
| bool | operator() (GT &g) |
| Invokes the acyclicity test. | |
Private Member Functions | |
| bool | is_acyclique (typename GT::Node *curr) |
| bool | is_acyclique (GT &g, size_t num_arcs, bool num_arcs_known=true) |
Private Attributes | |
| Kept_Filter< SA > | sa |
Determines whether a graph is acyclic (contains no cycles).
Is_Graph_Acyclique performs a depth-first search on graph g, starting from a node, and checks whether the graph is acyclic; i.e., that it contains no 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 71 of file tpl_test_acyclique.H.
|
inline |
Definition at line 158 of file tpl_test_acyclique.H.
|
inline |
Definition at line 162 of file tpl_test_acyclique.H.
|
inlineprivate |
Definition at line 131 of file tpl_test_acyclique.H.
References ah_domain_error_if, Aleph::and, GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::Is_Graph_Acyclique< GT, SA >::is_acyclique(), GraphCommon< GT, Node, Arc >::is_digraph(), IS_NODE_VISITED, GraphCommon< GT, Node, Arc >::reset_bit_arcs(), GraphCommon< GT, Node, Arc >::reset_bit_nodes(), and Aleph::Test_Cycle.
|
inlineprivate |
Definition at line 79 of file tpl_test_acyclique.H.
References Aleph::Dfs_Stack< T >::is_empty(), IS_NODE_VISITED, NODE_BITS, Aleph::Dfs_Stack< T >::pop(), Aleph::Dfs_Stack< T >::push(), Aleph::Is_Graph_Acyclique< GT, SA >::sa, Aleph::Test_Cycle, and Aleph::Dfs_Stack< T >::top().
Referenced by Aleph::Is_Graph_Acyclique< GT, SA >::is_acyclique(), Aleph::Is_Graph_Acyclique< GT, SA >::operator()(), and Aleph::Is_Graph_Acyclique< GT, SA >::operator()().
|
inline |
Invokes the acyclicity test.
With the default filter, which shows all the arcs, a graph with nodes and with as many arcs as nodes, or more, has a cycle, which is answered without a search; with another filter, which may hide arcs, the graph is searched. A loop is a cycle, and so are two arcs between the same nodes.
| [in] | g | the graph to test. |
| domain_error | if g is a digraph. |
Definition at line 206 of file tpl_test_acyclique.H.
References GraphCommon< GT, Node, Arc >::get_num_arcs(), and Aleph::Is_Graph_Acyclique< GT, SA >::is_acyclique().
|
inline |
Invokes the acyclicity test, with the number of arcs that the filter shows.
A forest has fewer arcs than nodes, so that a graph with nodes and with num_arcs as large as their number, or larger, has a cycle, which is answered without a search. A loop is a cycle, and so are two arcs between the same nodes.
| [in] | g | the graph to test. |
| [in] | num_arcs | number of arcs of g that the filter shows. This form serves a filter that hides arcs, whose number the routine cannot know otherwise. |
| domain_error | if g is a digraph. |
Definition at line 185 of file tpl_test_acyclique.H.
References Aleph::Is_Graph_Acyclique< GT, SA >::is_acyclique().
|
private |
Definition at line 73 of file tpl_test_acyclique.H.
Referenced by Aleph::Is_Graph_Acyclique< GT, SA >::is_acyclique().