|
Aleph-w 3.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 | |
| SN & | sn |
| 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 348 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 431 of file hamiltonian.H.
|
inline |
Find the vertex with minimum degree.
Useful for understanding why a graph fails Dirac's condition.
| g | The graph |
Definition at line 472 of file hamiltonian.H.
References GraphCommon< GT, Node, Arc >::get_num_arcs(), Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), and Aleph::Test_Dirac_Condition< GT, SN, SA >::sn.
Get the minimum degree required by Dirac's condition.
| g | The graph |
Definition at line 459 of file hamiltonian.H.
References GraphCommon< GT, Node, Arc >::get_num_nodes().
|
inline |
Test if a graph satisfies Dirac's Hamiltonian condition.
| g | Graph to test |
Definition at line 445 of file hamiltonian.H.
References GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Test_Dirac_Condition< GT, SN, SA >::test_digraph(), and Aleph::Test_Dirac_Condition< GT, SN, SA >::test_graph().
Test Dirac-like condition for directed graphs.
For digraphs, checks that min(out-deg, in-deg) ≥ n/2 for all vertices. This is a generalization of Dirac's theorem for directed graphs.
| g | Directed graph to test |
Definition at line 391 of file hamiltonian.H.
References GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_COUNTER, GraphCommon< GT, Node, Arc >::reset_counter_nodes(), 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()().
Test Dirac's condition for undirected graphs.
Checks that deg(v) ≥ n/2 for all vertices v.
| g | Undirected graph to test |
Definition at line 361 of file hamiltonian.H.
References GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), and Aleph::Test_Dirac_Condition< GT, SN, SA >::sn.
Referenced by Aleph::Test_Dirac_Condition< GT, SN, SA >::operator()().
|
private |
Definition at line 351 of file hamiltonian.H.
Referenced by Aleph::Test_Dirac_Condition< GT, SN, SA >::test_digraph().
|
private |
Definition at line 350 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().