|
Aleph-w 7.10.0
A C++ Library for Data Structures and Algorithms
|
Tests whether a graph or digraph is Eulerian. More...
#include <eulerian.H>
Public Member Functions | |
| Test_Eulerian (SN &&__sn=SN(), SA &&__sa=SA()) | |
| Construct an Eulerian tester with optional filters. | |
| Eulerian_Type | compute (GT &g) |
| Compute detailed Eulerian classification. | |
| bool | operator() (GT &g) |
| Test if a graph has an Eulerian cycle. | |
| bool | has_eulerian_path (GT &g) |
| Test if a graph has an Eulerian path. | |
| bool | test_degree_only (GT &g) |
| Check only degree conditions (without connectivity check). | |
Private Member Functions | |
| Eulerian_Type | analyze_graph (GT &g) |
| Analyze Eulerian properties of an undirected graph. | |
| Eulerian_Type | analyze_digraph (GT &g) |
| Analyze Eulerian properties of a directed graph. | |
Private Attributes | |
| Kept_Filter< SN > | sn |
| Kept_Filter< SA > | sa |
Tests whether a graph or digraph is Eulerian.
A graph is Eulerian if it contains an Eulerian cycle (a cycle that visits every edge exactly once). This class tests the necessary and sufficient conditions for Eulerian graphs.
Undirected graphs:
Directed graphs:
| 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 240 of file eulerian.H.
|
inline |
Construct an Eulerian tester with optional filters.
| __sn | Node filter (default: show all nodes) |
| __sa | Arc filter (default: show all arcs) |
Definition at line 329 of file eulerian.H.
|
inlineprivate |
Analyze Eulerian properties of a directed graph.
With every node balanced, or all but a start and an end, the arcs must be together; balanced, they are then strongly connected.
| g | The directed graph to test |
Definition at line 279 of file eulerian.H.
References Aleph::and, Aleph::eulerian_detail::arcs_are_together(), Aleph::Cycle, Aleph::eulerian_detail::degree(), Aleph::diff(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_COUNTER, Aleph::None, Aleph::Path, GraphCommon< GT, Node, Arc >::reset_counter_nodes(), Aleph::Test_Eulerian< GT, SN, SA >::sa, and Aleph::Test_Eulerian< GT, SN, SA >::sn.
Referenced by Aleph::Test_Eulerian< GT, SN, SA >::compute().
|
inlineprivate |
Analyze Eulerian properties of an undirected graph.
The degrees count a loop twice; the arcs must be together.
| g | The undirected graph to test |
Definition at line 253 of file eulerian.H.
References Aleph::and, Aleph::eulerian_detail::arcs_are_together(), Aleph::Cycle, Aleph::eulerian_detail::degree(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), Aleph::None, Aleph::Path, Aleph::Test_Eulerian< GT, SN, SA >::sa, and Aleph::Test_Eulerian< GT, SN, SA >::sn.
Referenced by Aleph::Test_Eulerian< GT, SN, SA >::compute().
|
inline |
Compute detailed Eulerian classification.
Determines whether the graph has an Eulerian cycle, path, or neither. This method checks both degree conditions AND connectivity.
| g | The graph to test |
Definition at line 352 of file eulerian.H.
References Aleph::Test_Eulerian< GT, SN, SA >::analyze_digraph(), Aleph::Test_Eulerian< GT, SN, SA >::analyze_graph(), and GraphCommon< GT, Node, Arc >::is_digraph().
Referenced by demo_eulerian_type(), Aleph::Test_Eulerian< GT, SN, SA >::has_eulerian_path(), Aleph::Test_Eulerian< GT, SN, SA >::operator()(), and Aleph::Find_Eulerian_Path< GT, SN, SA >::operator()().
|
inline |
Test if a graph has an Eulerian path.
An Eulerian path visits every edge exactly once but may not return to the starting vertex.
| g | The graph to test |
Definition at line 388 of file eulerian.H.
References Aleph::Test_Eulerian< GT, SN, SA >::compute(), Aleph::Cycle, and Aleph::Path.
Referenced by demo_eulerian_type().
|
inline |
Test if a graph has an Eulerian cycle.
Automatically detects whether the graph is directed or undirected and applies the appropriate test. This method checks both degree conditions AND connectivity.
| g | The graph to test |
Definition at line 372 of file eulerian.H.
References Aleph::Test_Eulerian< GT, SN, SA >::compute(), and Aleph::Cycle.
|
inline |
Check only degree conditions (without connectivity check).
This is faster but may return true for disconnected graphs that don't actually have Eulerian cycles/paths.
| g | The graph to test |
Definition at line 406 of file eulerian.H.
References Aleph::eulerian_detail::degree(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_COUNTER, GraphCommon< GT, Node, Arc >::reset_counter_nodes(), Aleph::Test_Eulerian< GT, SN, SA >::sa, and Aleph::Test_Eulerian< GT, SN, SA >::sn.
|
private |
Definition at line 243 of file eulerian.H.
Referenced by Aleph::Test_Eulerian< GT, SN, SA >::analyze_digraph(), Aleph::Test_Eulerian< GT, SN, SA >::analyze_graph(), and Aleph::Test_Eulerian< GT, SN, SA >::test_degree_only().
|
private |
Definition at line 242 of file eulerian.H.
Referenced by Aleph::Test_Eulerian< GT, SN, SA >::analyze_digraph(), Aleph::Test_Eulerian< GT, SN, SA >::analyze_graph(), and Aleph::Test_Eulerian< GT, SN, SA >::test_degree_only().