template<class TDigitalSurfaceContainer>
class boost::graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::adjacency_iterator
Iterator for visiting adjacent vertices. 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 shares the container of adjacent vertices (a std::vector) with other (potentially) iterators, through a DGtal::CountedPtr. When the last iterator pointing in this structure is desallocated, the container is automatically desallocated. This is for instance used by function adjacent_vertices, which returns a pair of adjacency_iterator, both points on the same container. Another problem is that the user may have called twice adjacent_vertices on the same vertex, and may wish to compare iterators obtained by two different calls.
typedef typename DigitalSurface<...> G;
G g(...);
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::adjacency_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::adjacency_iterator > adjacent_vertices(typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor u, 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 adjacency_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 172 of file DigitalSurfaceBoostGraphInterface.h.