|
Aleph-w 3.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 | |
| bool | is_connected (GT &g) |
| Check connectivity of undirected graph using DFS. | |
| bool | is_strongly_connected (GT &g) |
| Check strong connectivity of digraph using Kosaraju-like approach. | |
| 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 | |
| SN & | sn |
| 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 170 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 413 of file eulerian.H.
|
inlineprivate |
Analyze Eulerian properties of a directed graph.
| g | The directed graph to test |
Definition at line 349 of file eulerian.H.
References Aleph::Cycle, Aleph::diff(), GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::Test_Eulerian< GT, SN, SA >::is_strongly_connected(), Aleph::maps(), 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.
| g | The undirected graph to test |
Definition at line 307 of file eulerian.H.
References Aleph::Cycle, GraphCommon< GT, Node, Arc >::get_num_arcs(), Aleph::Test_Eulerian< GT, SN, SA >::is_connected(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), Aleph::None, Aleph::Path, 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 436 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 Aleph::Test_Eulerian< GT, SN, SA >::has_eulerian_path(), and Aleph::Test_Eulerian< GT, SN, SA >::operator()().
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 472 of file eulerian.H.
References Aleph::Test_Eulerian< GT, SN, SA >::compute(), Aleph::Cycle, and Aleph::Path.
Check connectivity of undirected graph using DFS.
Only considers vertices with degree > 0 (isolated vertices don't affect Eulerian properties).
| g | The undirected graph |
Definition at line 184 of file eulerian.H.
References Aleph::Depth_First, GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::DynList< T >::insert(), Aleph::HTList::is_empty(), Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_BITS, Aleph::DynList< T >::remove_first(), GraphCommon< GT, Node, Arc >::reset_nodes(), Aleph::Test_Eulerian< GT, SN, SA >::sa, and Aleph::Test_Eulerian< GT, SN, SA >::sn.
Referenced by Aleph::Test_Eulerian< GT, SN, SA >::analyze_graph().
Check strong connectivity of digraph using Kosaraju-like approach.
For Eulerian cycle in digraph, we need strong connectivity among vertices with edges.
| g | The directed graph |
Definition at line 244 of file eulerian.H.
References Aleph::Depth_First, GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::get_num_nodes(), Aleph::DynList< T >::insert(), Aleph::HTList::is_empty(), Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_BITS, NODE_COUNTER, Aleph::DynList< T >::remove_first(), GraphCommon< GT, Node, Arc >::reset_nodes(), Aleph::Test_Eulerian< GT, SN, SA >::sa, and Aleph::Test_Eulerian< GT, SN, SA >::sn.
Referenced by Aleph::Test_Eulerian< GT, SN, SA >::analyze_digraph().
|
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 456 of file eulerian.H.
References Aleph::Test_Eulerian< GT, SN, SA >::compute(), and Aleph::Cycle.
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 490 of file eulerian.H.
References GraphCommon< GT, Node, Arc >::get_num_arcs(), 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 |
|
private |
Definition at line 172 of file eulerian.H.
Referenced by Aleph::Test_Eulerian< GT, SN, SA >::analyze_digraph(), Aleph::Test_Eulerian< GT, SN, SA >::analyze_graph(), Aleph::Test_Eulerian< GT, SN, SA >::is_connected(), Aleph::Test_Eulerian< GT, SN, SA >::is_strongly_connected(), and Aleph::Test_Eulerian< GT, SN, SA >::test_degree_only().