abLEMON 1.9.0-101-gccb8629
A maintained fork of LEMON
Loading...
Searching...
No Matches
EulerIt< GR > Class Template Reference

Euler tour iterator for graphs. More...

#include <lemon/euler.h>

Public Member Functions

 EulerIt (const GR &gr, typename GR::Node start=INVALID)
 Constructor.
 operator Arc () const
 Arc conversion.
 operator Edge () const
 Edge conversion.
bool operator== (Invalid) const
 Compare with INVALID.
bool operator!= (Invalid) const
 Compare with INVALID.
EulerIt & operator++ ()
 Next arc of the tour.
Arc operator++ (int)
 Postfix incrementation.

Detailed Description

template< typename GR >
class lemon::EulerIt< GR >

This iterator provides an Euler tour (Eulerian circuit) of an undirected graph (if there exists) and it converts to the Arc and Edge types of the graph.

For example, if the given graph has an Euler tour (i.e it has only one non-trivial component and the degree of each node is even), the following code will print the arc IDs according to an Euler tour of g.

for( EulerIt< ListGraph > e( g ) ; e != INVALID ; ++e )
{
std::cout << g.id( Edge( e ) ) << std::eol;
}
EulerIt( const GR & gr , typename GR::Node start=INVALID )
Constructor.
Definition euler.h:180
const Invalid INVALID
Invalid iterators.
Definition base.cc:33

Although this iterator is for undirected graphs, it still returns arcs in order to indicate the direction of the tour. (But arcs convert to edges, of course.)

If g has no Euler tour, then the resulted walk will not be closed or not contain all edges.

Constructor & Destructor Documentation

◆ EulerIt()

template< typename GR >
EulerIt ( const GR & gr,
typename GR::Node start = INVALID )
inline

Constructor.

Parameters
grA graph.
startThe starting point of the tour. If it is not given, the tour will start from the first node that has an incident edge.

Member Function Documentation

◆ operator++() [1/2]

template< typename GR >
EulerIt & operator++ ( )
inline

Next arc of the tour

◆ operator++() [2/2]

template< typename GR >
Arc operator++ ( int )
inline

Postfix incrementation.

Warning
This incrementation returns an Arc (which converts to an Edge), not an EulerIt, as one may expect.