|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Tests Ore's sufficient condition for Hamiltonian graphs. More...
#include <hamiltonian.H>
Public Member Functions | |
| Test_Hamiltonian_Sufficiency (SN &&__sn=SN(), SA &&__sa=SA()) | |
| Construct a Hamiltonian sufficiency tester. | |
| bool | operator() (GT &g) |
| Test if a graph satisfies Ore's Hamiltonian condition. | |
Private Member Functions | |
| bool | are_adjacent (GT &g, typename GT::Node *src, typename GT::Node *tgt) |
| Check if two nodes are adjacent in an undirected graph. | |
| bool | test_graph (GT &g) |
| Test Ore's condition for undirected graphs. | |
| bool | has_arc (typename GT::Node *src, typename GT::Node *tgt) |
| Check if arc src→tgt exists in a digraph. | |
| bool | test_digraph (GT &g) |
| Test Ore-like condition for directed graphs. | |
Private Attributes | |
| SN & | sn |
| SA & | sa |
Tests Ore's sufficient condition for Hamiltonian graphs.
This class tests whether a graph satisfies Ore's theorem, which provides a sufficient (but not necessary) condition for a graph to be Hamiltonian.
For an undirected graph G with n ≥ 3 vertices: if for every pair of non-adjacent vertices u and v, deg(u) + deg(v) ≥ n, then G has a Hamiltonian cycle.
For directed graphs, the condition is extended to in-degree + out-degree.
| 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 130 of file hamiltonian.H.
|
inline |
Construct a Hamiltonian sufficiency tester.
| __sn | Node filter (default: show all nodes) |
| __sa | Arc filter (default: show all arcs) |
Definition at line 279 of file hamiltonian.H.
|
inlineprivate |
Check if two nodes are adjacent in an undirected graph.
| [in] | g | The graph |
| [in] | src | First node |
| [in] | tgt | Second node |
Definition at line 143 of file hamiltonian.H.
References Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), and Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::sa.
Referenced by Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::test_graph().
|
inlineprivate |
Check if arc src→tgt exists in a digraph.
| src | Source node |
| tgt | Target node |
Definition at line 206 of file hamiltonian.H.
References Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), and Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::sa.
Referenced by Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::test_digraph().
|
inline |
Test if a graph satisfies Ore's Hamiltonian condition.
Automatically detects directed vs undirected and applies the appropriate test.
| g | Graph to test |
Definition at line 297 of file hamiltonian.H.
References GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::test_digraph(), and Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::test_graph().
Test Ore-like condition for directed graphs.
For digraphs, checks that for each pair (u,v) without arc u→v: out-deg(u) + in-deg(v) ≥ n
This is based on Ghouila-Houri's theorem extension for digraphs.
| g | Directed graph to test |
Definition at line 225 of file hamiltonian.H.
References GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::has_arc(), 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_Hamiltonian_Sufficiency< GT, SN, SA >::sa, and Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::sn.
Referenced by Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::operator()().
Test Ore's condition for undirected graphs.
Checks that for all pairs of NON-ADJACENT vertices u, v: deg(u) + deg(v) ≥ n
| g | Undirected graph to test |
Definition at line 162 of file hamiltonian.H.
References Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::are_adjacent(), 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_Hamiltonian_Sufficiency< GT, SN, SA >::sn.
Referenced by Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::operator()().
|
private |
Definition at line 133 of file hamiltonian.H.
Referenced by Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::are_adjacent(), Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::has_arc(), and Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::test_digraph().
|
private |
Definition at line 132 of file hamiltonian.H.
Referenced by Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::test_digraph(), and Aleph::Test_Hamiltonian_Sufficiency< GT, SN, SA >::test_graph().