DGtal  1.4.beta
boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator Class Reference

#include <DGtal/graph/ObjectBoostGraphInterface.h>

Inheritance diagram for boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator:
[legend]

Public Member Functions

 edge_iterator ()
 Default, invalid, constructor. More...
 
 edge_iterator (const Adapted &graph, const vertex_iterator &itB, const vertex_iterator &itE)
 

Private Member Functions

const Edgedereference () const
 
bool equal (const edge_iterator &other) const
 
void increment ()
 

Private Attributes

const AdaptedmyGraph
 Graph to iterate from. More...
 
std::pair< vertex_iterator, vertex_iteratormyVertexRange
 Vertex Range to iterator from. Set at constructor. More...
 
std::pair< out_edge_iterator, out_edge_iterator > myOutEdgeRange
 Local pair of out_edge_iterator. Created within this iterator. More...
 

Friends

class iterator_core_access
 Requirement for boost::iterator_facade. More...
 

Detailed Description

template<class TDigitalTopology, class TDigitalSet>
class boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator

Iterator for visiting all edges of the graph. We use an iterator facade to create a STL-compliant iterator with as little effort as possible.

Note
The difficulty is that DGtal graphs do not provide iterators for visiting edges or adjacent vertices, but merely provide a method that outputs them. Therefore, this iterator mixes a vertex_iterator (to visit all vertices) and a local out_edge_iterator (to visit all out edges of each vertex). This is for instance used by function edges, which returns a pair of edge_iterator. A potential problem is that the user may have called twice edges, and may wish to compare iterators obtained by two different calls. Here, edges are constructed on the fly, hence iterators may not point on the same container even if the values are the same.
typedef typename Object<...> G;
typedef typename graph_traits<G>::edge_iterator edge_iterator;
G g(...);
std::pair<edge_iterator,edge_iterator> vp1 = boost::edges( g );
std::pair<edge_iterator,edge_iterator> vp2 = boost::edges( g );
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator > edges(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)

In this case, vp1 and vp2 are not pointing on the same structure, hence the address pointed by vp1 is different from the address pointed by vp2. They are then not comparable a priori. The edge_iterator is written so that vp1 (.first or .second) and vp2 (.first or .second) are comparable, using value comparison and out-of-range check.

Definition at line 398 of file ObjectBoostGraphInterface.h.

Constructor & Destructor Documentation

◆ edge_iterator() [1/2]

template<class TDigitalTopology , class TDigitalSet >
boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator::edge_iterator ( )

Default, invalid, constructor.

◆ edge_iterator() [2/2]

template<class TDigitalTopology , class TDigitalSet >
boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator::edge_iterator ( const Adapted graph,
const vertex_iterator itB,
const vertex_iterator itE 
)

Valid constructor from instance of an Object (Graph), and begin/end vertex_iterators. This iterator mixes a vertex_iterator (to visit all vertices) and a local out_edge_iterator (to visit all out edges of each vertex).

Parameters
graphvalid Object.
itBbegin vertex_iterator of graph.
itEend vertex_iterator of graph.

Member Function Documentation

◆ dereference()

template<class TDigitalTopology , class TDigitalSet >
const Edge& boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator::dereference ( ) const
private
Returns
const reference to the Edge the iterator is pointing to. Required for Readable Iterator, Writable Iterator Concepts

◆ equal()

template<class TDigitalTopology , class TDigitalSet >
bool boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator::equal ( const edge_iterator other) const
private

Predicate to compare equal value of iterators. Required to implement Single Pass Iterator Concept.

Parameters
otheredge_iterator to compare with.
Returns
true iff other and this refer to the same Edge.

◆ increment()

template<class TDigitalTopology , class TDigitalSet >
void boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator::increment ( )
private

Increment iterator. Required to implement Incrementable Iterator Concept.

Friends And Related Function Documentation

◆ iterator_core_access

template<class TDigitalTopology , class TDigitalSet >
friend class iterator_core_access
friend

Requirement for boost::iterator_facade.

Definition at line 451 of file ObjectBoostGraphInterface.h.

Field Documentation

◆ myGraph

template<class TDigitalTopology , class TDigitalSet >
const Adapted* boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator::myGraph
private

Graph to iterate from.

Definition at line 444 of file ObjectBoostGraphInterface.h.

◆ myOutEdgeRange

template<class TDigitalTopology , class TDigitalSet >
std::pair< out_edge_iterator, out_edge_iterator > boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator::myOutEdgeRange
private

Local pair of out_edge_iterator. Created within this iterator.

Definition at line 448 of file ObjectBoostGraphInterface.h.

◆ myVertexRange

template<class TDigitalTopology , class TDigitalSet >
std::pair< vertex_iterator, vertex_iterator > boost::graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator::myVertexRange
private

Vertex Range to iterator from. Set at constructor.

Definition at line 446 of file ObjectBoostGraphInterface.h.


The documentation for this class was generated from the following file: