|
Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
|
Finds and constructs an Eulerian path or cycle using Hierholzer's algorithm. More...
#include <eulerian.H>
Classes | |
| struct | Result |
| Result type: path and its classification. More... | |
Public Member Functions | |
| Find_Eulerian_Path (SN &&__sn=SN(), SA &&__sa=SA()) | |
| Construct an Eulerian path finder with optional filters. | |
| Result | operator() (GT &g) |
| Find an Eulerian path or cycle in the graph. | |
| DynList< typename GT::Arc * > | find_path (GT &g) |
| Get only the arc list (convenience method). | |
| DynList< typename GT::Node * > | find_node_sequence (GT &g) |
| Get the node sequence of the Eulerian path/cycle. | |
Private Member Functions | |
| GT::Node * | find_start_vertex (GT &g, Eulerian_Type type) |
| Find starting vertex for Eulerian path/cycle. | |
| DynList< typename GT::Arc * > | hierholzer_undirected (GT &g, typename GT::Node *start) |
| Hierholzer's algorithm for undirected graphs. | |
| DynList< typename GT::Arc * > | hierholzer_directed (GT &g, typename GT::Node *start) |
| Hierholzer's algorithm for directed graphs. | |
Private Attributes | |
| SN & | sn |
| SA & | sa |
Finds and constructs an Eulerian path or cycle using Hierholzer's algorithm.
Hierholzer's algorithm efficiently constructs an Eulerian path or cycle in O(E) time. It works by:
| 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 560 of file eulerian.H.
|
inline |
Construct an Eulerian path finder with optional filters.
| __sn | Node filter (default: show all nodes) |
| __sa | Arc filter (default: show all arcs) |
Definition at line 754 of file eulerian.H.
|
inline |
Get the node sequence of the Eulerian path/cycle.
| g | The graph |
Definition at line 833 of file eulerian.H.
References Aleph::Dlink::append(), Aleph::Find_Eulerian_Path< GT, SN, SA >::find_start_vertex(), GraphCommon< GT, Node, Arc >::get_connected_node(), Aleph::DynList< T >::get_first(), GraphCommon< GT, Node, Arc >::get_src_node(), GraphCommon< GT, Node, Arc >::get_tgt_node(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::HTList::is_empty(), Aleph::maps(), nodes, Aleph::None, Aleph::Find_Eulerian_Path< GT, SN, SA >::Result::path, and Aleph::Find_Eulerian_Path< GT, SN, SA >::Result::type.
Get only the arc list (convenience method).
| g | The graph to search |
Definition at line 822 of file eulerian.H.
|
inlineprivate |
Find starting vertex for Eulerian path/cycle.
For cycles: any vertex with edges For paths: a vertex with odd degree (undirected) or out-in=1 (directed)
| g | The graph |
| type | The Eulerian type (Cycle or Path) |
Definition at line 575 of file eulerian.H.
References GraphCommon< GT, Node, Arc >::get_num_arcs(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::maps(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), NODE_COUNTER, Aleph::Path, GraphCommon< GT, Node, Arc >::reset_counter_nodes(), Aleph::Find_Eulerian_Path< GT, SN, SA >::sa, and Aleph::Find_Eulerian_Path< GT, SN, SA >::sn.
Referenced by Aleph::Find_Eulerian_Path< GT, SN, SA >::find_node_sequence(), and Aleph::Find_Eulerian_Path< GT, SN, SA >::operator()().
|
inlineprivate |
Hierholzer's algorithm for directed graphs.
| g | The directed graph |
| start | Starting vertex |
Definition at line 691 of file eulerian.H.
References ARC_BITS, Aleph::Depth_First, Aleph::DynList< T >::get_first(), GraphCommon< GT, Node, Arc >::get_tgt_node(), Aleph::DynList< T >::insert(), IS_ARC_VISITED, Aleph::HTList::is_empty(), Aleph::maps(), Aleph::next(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), Aleph::DynList< T >::remove_first(), GraphCommon< GT, Node, Arc >::reset_arcs(), and Aleph::Find_Eulerian_Path< GT, SN, SA >::sa.
Referenced by Aleph::Find_Eulerian_Path< GT, SN, SA >::operator()().
|
inlineprivate |
Hierholzer's algorithm for undirected graphs.
| g | The undirected graph |
| start | Starting vertex |
Definition at line 629 of file eulerian.H.
References ARC_BITS, Aleph::Depth_First, GraphCommon< GT, Node, Arc >::get_connected_node(), Aleph::DynList< T >::get_first(), Aleph::DynList< T >::insert(), IS_ARC_VISITED, Aleph::HTList::is_empty(), Aleph::maps(), Aleph::next(), Aleph::Filter_Iterator< Container, It, Show_Item >::next_ne(), Aleph::DynList< T >::remove_first(), GraphCommon< GT, Node, Arc >::reset_arcs(), and Aleph::Find_Eulerian_Path< GT, SN, SA >::sa.
Referenced by Aleph::Find_Eulerian_Path< GT, SN, SA >::operator()().
|
inline |
Find an Eulerian path or cycle in the graph.
| g | The graph to search |
Definition at line 787 of file eulerian.H.
References Aleph::Find_Eulerian_Path< GT, SN, SA >::find_start_vertex(), Aleph::Find_Eulerian_Path< GT, SN, SA >::hierholzer_directed(), Aleph::Find_Eulerian_Path< GT, SN, SA >::hierholzer_undirected(), GraphCommon< GT, Node, Arc >::is_digraph(), Aleph::maps(), Aleph::None, Aleph::Find_Eulerian_Path< GT, SN, SA >::Result::path, Aleph::Find_Eulerian_Path< GT, SN, SA >::sa, Aleph::Find_Eulerian_Path< GT, SN, SA >::sn, and Aleph::Find_Eulerian_Path< GT, SN, SA >::Result::type.
|
private |
Definition at line 563 of file eulerian.H.
Referenced by Aleph::Find_Eulerian_Path< GT, SN, SA >::find_start_vertex(), Aleph::Find_Eulerian_Path< GT, SN, SA >::hierholzer_directed(), Aleph::Find_Eulerian_Path< GT, SN, SA >::hierholzer_undirected(), and Aleph::Find_Eulerian_Path< GT, SN, SA >::operator()().
|
private |
Definition at line 562 of file eulerian.H.
Referenced by Aleph::Find_Eulerian_Path< GT, SN, SA >::find_start_vertex(), and Aleph::Find_Eulerian_Path< GT, SN, SA >::operator()().