31 #if defined(ObjectBoostGraphInterface_RECURSES)
32 #error Recursive header files inclusion detected in ObjectBoostGraphInterface.h
35 #define ObjectBoostGraphInterface_RECURSES
37 #if !defined ObjectBoostGraphInterface_h
39 #define ObjectBoostGraphInterface_h
45 #include <boost/iterator/iterator_facade.hpp>
46 #include <boost/graph/graph_traits.hpp>
47 #include <boost/graph/properties.hpp>
48 #include <boost/property_map/property_map.hpp>
49 #include "DGtal/base/Common.h"
50 #include "DGtal/base/CountedPtr.h"
51 #include "DGtal/topology/Object.h"
85 template <
class TDigitalTopology,
class TDigitalSet >
86 struct graph_traits<
DGtal::Object< TDigitalTopology, TDigitalSet > >
165 class adjacency_iterator
166 :
public iterator_facade< adjacency_iterator,
168 bidirectional_traversal_tag,
175 : myIterator(), myVertices( 0 ) {}
189 : myIterator( it ), myVertices(
vertices ) {}
199 ASSERT( myIterator != myVertices->end() );
212 bool equal(
const adjacency_iterator& other)
const
214 bool thisAtEnd = ( myIterator == myVertices->end() );
215 bool otherAtEnd = ( other.myIterator == other.myVertices->end() );
216 if ( thisAtEnd || otherAtEnd )
return thisAtEnd && otherAtEnd;
217 else return *myIterator == *other.myIterator;
246 friend class iterator_core_access;
282 class out_edge_iterator
283 :
public iterator_facade< out_edge_iterator,
285 bidirectional_traversal_tag,
292 : myIterator(), myOutEdges( 0 ) {}
305 : myIterator( it ), myOutEdges(
out_edges ) {}
314 ASSERT( myIterator != myOutEdges->end() );
327 bool equal(
const out_edge_iterator & other)
const
329 bool thisAtEnd = ( myIterator == myOutEdges->end() );
330 bool otherAtEnd = ( other.myIterator == other.myOutEdges->end() );
331 if ( thisAtEnd || otherAtEnd )
return thisAtEnd && otherAtEnd;
332 else return *myIterator == *other.myIterator;
357 friend class iterator_core_access;
399 :
public iterator_facade< edge_iterator,
401 forward_traversal_tag,
435 bool equal(
const edge_iterator & other)
const;
451 friend class iterator_core_access;
465 template <
class TDigitalTopology,
class TDigitalSet >
467 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::vertex_descriptor
471 return obj.tail( edge );
478 template <
class TDigitalTopology,
class TDigitalSet >
480 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::vertex_descriptor
484 return obj.head( edge );
492 template <
class TDigitalTopology,
class TDigitalSet >
494 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::vertex_iterator,
495 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::vertex_iterator
503 template <
class TDigitalTopology,
class TDigitalSet >
505 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::vertices_size_type
518 template <
class TDigitalTopology,
class TDigitalSet >
521 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::adjacency_iterator,
522 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::adjacency_iterator
527 typedef typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >
528 ::adjacency_iterator Iterator;
529 typedef typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >
532 std::back_insert_iterator< Container > outIt = std::back_inserter( *ptrAdjVertices );
533 obj.writeNeighbors( outIt, u );
534 return std::make_pair( Iterator( ptrAdjVertices->begin(), ptrAdjVertices ),
535 Iterator( ptrAdjVertices->end(), ptrAdjVertices ) );
547 template <
class TDigitalTopology,
class TDigitalSet >
550 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::out_edge_iterator,
551 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::out_edge_iterator
556 typedef typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >
557 ::out_edge_iterator Iterator;
558 typedef typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >
561 return std::make_pair( Iterator( ptrEdges->begin(), ptrEdges ),
562 Iterator( ptrEdges->end(), ptrEdges ) );
572 template <
class TDigitalTopology,
class TDigitalSet >
574 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::degree_size_type
578 return obj.degree( u );
587 template <
class TDigitalTopology,
class TDigitalSet >
590 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator,
591 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator
595 typedef typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator
597 return std::make_pair( edge_iterator( obj, obj.begin(), obj.end() ),
598 edge_iterator( obj, obj.end(), obj.end() ) );
605 template <
class TDigitalTopology,
class TDigitalSet >
607 typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edges_size_type
610 typedef typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edge_iterator
612 typedef typename graph_traits< DGtal::Object< TDigitalTopology, TDigitalSet > >::edges_size_type
614 edges_size_type nbEdges = 0;
615 for ( std::pair< edge_iterator, edge_iterator > ve =
boost::edges( obj );
616 ve.first != ve.second; ++ve.first )
626 #include "DGtal/graph/ObjectBoostGraphInterface.ih"
633 #undef ObjectBoostGraphInterface_RECURSES
Aim: An object (or digital object) represents a set in some digital space associated with a digital t...
std::vector< Edge > EdgeRange
DigitalSet::ConstIterator ConstIterator
AdjacentVertexContainer::const_iterator myIterator
The iterator pointing in the container of adjacent vertices.
bool equal(const adjacency_iterator &other) const
adjacency_iterator(typename AdjacentVertexContainer::const_iterator it, const DGtal::CountedPtr< AdjacentVertexContainer > &vertices)
DGtal::CountedPtr< AdjacentVertexContainer > myVertices
const Vertex & dereference() const
adjacency_iterator()
Default, invalid, constructor.
edge_iterator()
Default, invalid, constructor.
const Adapted * myGraph
Graph to iterate from.
std::pair< out_edge_iterator, out_edge_iterator > myOutEdgeRange
Local pair of out_edge_iterator. Created within this iterator.
bool equal(const edge_iterator &other) const
std::pair< vertex_iterator, vertex_iterator > myVertexRange
Vertex Range to iterator from. Set at constructor.
const Edge & dereference() const
edge_iterator(const Adapted &graph, const vertex_iterator &itB, const vertex_iterator &itE)
bool equal(const out_edge_iterator &other) const
out_edge_iterator()
Default, invalid, constructor.
DGtal::CountedPtr< OutEdgeContainer > myOutEdges
out_edge_iterator(typename OutEdgeContainer::const_iterator it, const DGtal::CountedPtr< OutEdgeContainer > &out_edges)
const Edge & dereference() const
OutEdgeContainer::const_iterator myIterator
The iterator pointing in the container of out edges.
DGtal is the top-level namespace which contains all DGtal functions and types.
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_iterator > edges(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edges_size_type num_edges(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
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)
graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertices_size_type num_vertices(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor source(typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_descriptor edge, const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::degree_size_type out_degree(typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor u, const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::out_edge_iterator > out_edges(typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor u, const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
std::pair< typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator, typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_iterator > vertices(const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::vertex_descriptor target(typename graph_traits< DGtal::DigitalSurface< TDigitalSurfaceContainer > >::edge_descriptor edge, const DGtal::DigitalSurface< TDigitalSurfaceContainer > &digSurf)
Go to http://www.sgi.com/tech/stl/Container.html.
static vertex_descriptor null_vertex()
Edge edge_descriptor
(oriented) edge type
Adapted::ConstIterator vertex_iterator
Adapted::Size vertices_size_type
the type for counting vertices
undirected_tag directed_category
the graph is undirected.
DGtal::Object< TDigitalTopology, TDigitalSet > Adapted
the adapted DGtal graph class.
Adapted::Size degree_size_type
the type for counting out or in edges
disallow_parallel_edge_tag edge_parallel_category
the graph does not allow parallel edges.
Object_graph_traversal_category traversal_category
the graph satisfies AdjacencyListGraph and VertexListGraph concepts.
Vertex vertex_descriptor
Vertex type.
Adapted::Vertex Vertex
Vertex type.
Adapted::Edge Edge
(oriented) edge type
Adapted::EdgeRange OutEdgeContainer
This is the intermediate data structure that is used for storing out edges.
out_edge_iterator in_edge_iterator
Adapted::Size edges_size_type
the type for counting edges
std::vector< vertex_descriptor > AdjacentVertexContainer
This is the intermediate data structure that is used for visiting adjacent vertices.