|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Tests Dirac's sufficient condition for Hamiltonian graphs. More...
#include <hamiltonian.H>
Public Member Functions | |
| Test_Dirac_Condition (SN &&__sn=SN(), SA &&__sa=SA()) | |
| Construct a Dirac condition tester. | |
| bool | operator() (GT &g) |
| Test if a graph satisfies Dirac's Hamiltonian condition. | |
| size_t | min_required_degree (GT &g) const |
| Get the minimum degree required by Dirac's condition. | |
| std::pair< size_t, typename GT::Node * > | find_min_degree_vertex (GT &g) |
| Find the vertex with minimum degree. | |
Private Member Functions | |
| bool | test_graph (GT &g) |
| Test Dirac's condition for undirected graphs. | |
| bool | test_digraph (GT &g) |
| Test Dirac-like condition for directed graphs. | |
Private Attributes | |
| Kept_Filter< SN > | sn |
| Kept_Filter< SA > | sa |
Tests Dirac's sufficient condition for Hamiltonian graphs.
Dirac's theorem provides a simpler sufficient condition than Ore's: For an undirected simple graph G with n ≥ 3 vertices, if deg(v) ≥ n/2 for every vertex v, then G is Hamiltonian.
| Property | Dirac | Ore |
|---|---|---|
| Complexity | O(V) | O(V²) |
| Condition | deg(v) ≥ n/2 for all v | deg(u)+deg(v) ≥ n for non-adjacent |
| Strictness | More restrictive | Less restrictive |
| GT | Graph type (List_Graph, Array_Graph, etc.) |
| SN | Node filter for iteration (default: show all nodes) |
| SA | Arc filter for iteration (default: show all arcs) |
Definition at line 357 of file hamiltonian.H.
|
inline |
Construct a Dirac condition tester.
| __sn | Node filter (default: show all nodes) |
| __sa | Arc filter (default: show all arcs) |
Definition at line 430 of file hamiltonian.H.
|
inline |
Find the vertex with minimum degree.
Useful for understanding why a graph fails Dirac's condition: the degree is the one that the condition takes, in the simple graph of the arcs that the filter shows; in a digraph, the least of the degrees in and out.
| g | The graph |
Definition at line 474 of file hamiltonian.H.
References Aleph::hamiltonian_detail::Simple_Graph< GT, SA >::degree(), Aleph::hamiltonian_detail::Simple_Graph< GT, SA >::in_degree(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), Aleph::Test_Dirac_Condition< GT, SN, SA >::sa, and Aleph::Test_Dirac_Condition< GT, SN, SA >::sn.
Referenced by demo_dirac().
|
inline |
Get the minimum degree required by Dirac's condition.
| g | The graph |
Definition at line 458 of file hamiltonian.H.
References GraphCommon< GT, Node, Arc >::get_num_nodes().
Referenced by demo_dirac().
|
inline |
Test if a graph satisfies Dirac's Hamiltonian condition.
| g | Graph to test |
Definition at line 444 of file hamiltonian.H.
References GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Test_Dirac_Condition< GT, SN, SA >::test_digraph(), and test_graph().
|
inlineprivate |
Test Dirac-like condition for directed graphs.
Checks that in-deg(v) ≥ n/2 and out-deg(v) ≥ n/2 for all v, in the simple digraph of the arcs that the filter shows (Ghouila-Houri).
| g | Directed graph to test |
Definition at line 400 of file hamiltonian.H.
References Aleph::hamiltonian_detail::Simple_Graph< GT, SA >::degree(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::hamiltonian_detail::Simple_Graph< GT, SA >::in_degree(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), Aleph::Test_Dirac_Condition< GT, SN, SA >::sa, and Aleph::Test_Dirac_Condition< GT, SN, SA >::sn.
Referenced by Aleph::Test_Dirac_Condition< GT, SN, SA >::operator()().
|
inlineprivate |
Test Dirac's condition for undirected graphs.
Checks that deg(v) ≥ n/2 for all vertices v, in the simple graph of the arcs that the filter shows.
| g | Undirected graph to test |
Definition at line 371 of file hamiltonian.H.
References Aleph::hamiltonian_detail::Simple_Graph< GT, SA >::degree(), GraphCommon< GT, Node, Arc >::get_num_nodes(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), Aleph::Test_Dirac_Condition< GT, SN, SA >::sa, and Aleph::Test_Dirac_Condition< GT, SN, SA >::sn.
|
private |
Definition at line 360 of file hamiltonian.H.
Referenced by Aleph::Test_Dirac_Condition< GT, SN, SA >::find_min_degree_vertex(), Aleph::Test_Dirac_Condition< GT, SN, SA >::test_digraph(), and Aleph::Test_Dirac_Condition< GT, SN, SA >::test_graph().
|
private |
Definition at line 359 of file hamiltonian.H.
Referenced by Aleph::Test_Dirac_Condition< GT, SN, SA >::find_min_degree_vertex(), Aleph::Test_Dirac_Condition< GT, SN, SA >::test_digraph(), and Aleph::Test_Dirac_Condition< GT, SN, SA >::test_graph().