1 #ifndef GRAPH_ANALYSIS_BOOST_GRAPH_ARC_ITERATOR_HPP 2 #define GRAPH_ANALYSIS_BOOST_GRAPH_ARC_ITERATOR_HPP 4 #include "../EdgeIterator.hpp" 5 #include "../Vertex.hpp" 6 #include <boost/graph/adjacency_list.hpp> 9 namespace boost_graph {
14 typedef typename boost::graph_traits< typename T::graph_t >::edge_iterator EdgeIteratorImpl;
15 typedef typename boost::graph_traits< typename T::graph_t >::edge_descriptor EdgeDescriptor;
21 boost::tie(mStart, mEnd) = boost::edges(mGraph.raw());
27 while( mCurrent != mEnd)
29 EdgeDescriptor edgeDescriptor = *mCurrent;
30 Edge::Ptr edge = mGraph.raw()[edgeDescriptor];
43 EdgeIteratorImpl mCurrent;
44 EdgeIteratorImpl mStart;
45 EdgeIteratorImpl mEnd;
53 typedef typename boost::graph_traits< typename T::graph_t >::out_edge_iterator EdgeIteratorImpl;
54 typedef typename boost::graph_traits< typename T::graph_t >::edge_descriptor EdgeDescriptor;
55 typedef typename boost::graph_traits< typename T::graph_t >::vertex_descriptor
VertexDescriptor;
62 typename T::VertexMap::const_iterator cit = mGraph.mVertexMap.find(
id);
63 if(cit == mGraph.mVertexMap.end())
65 throw std::invalid_argument(
"graph_analysis::boost_graph::OutArcIterator: '" + vertex->toString() +
"' is not part of this graph");
67 VertexDescriptor vertexDescriptor = cit->second;
68 boost::tie(mStart, mEnd) = boost::out_edges(vertexDescriptor, mGraph.raw());
74 while( mCurrent != mEnd)
76 EdgeDescriptor edgeDescriptor = *mCurrent;
77 Edge::Ptr edge = mGraph.raw()[edgeDescriptor];
90 EdgeIteratorImpl mCurrent;
91 EdgeIteratorImpl mStart;
92 EdgeIteratorImpl mEnd;
100 typedef typename boost::graph_traits< typename T::graph_t >::in_edge_iterator EdgeIteratorImpl;
101 typedef typename boost::graph_traits< typename T::graph_t >::edge_descriptor EdgeDescriptor;
102 typedef typename boost::graph_traits< typename T::graph_t >::vertex_descriptor
VertexDescriptor;
109 typename T::VertexMap::const_iterator cit = mGraph.mVertexMap.find(
id);
110 if(cit == mGraph.mVertexMap.end())
112 throw std::invalid_argument(
"graph_analysis::boost_graph::InArcIterator: '" + vertex->toString() +
"' is not part of this graph");
114 VertexDescriptor vertexDescriptor = cit->second;
115 boost::tie(mStart, mEnd) = boost::in_edges(vertexDescriptor, mGraph.raw());
121 while( mCurrent != mEnd)
123 EdgeDescriptor edgeDescriptor = *mCurrent;
124 Edge::Ptr edge = mGraph.raw()[edgeDescriptor];
137 EdgeIteratorImpl mCurrent;
138 EdgeIteratorImpl mStart;
139 EdgeIteratorImpl mEnd;
150 , mInArcIterator(graph, vertex)
151 , mOutArcIterator(graph, vertex)
156 if(mInArcIterator.next())
158 setNext( mInArcIterator.current() );
162 if(mOutArcIterator.next())
164 setNext( mOutArcIterator.current() );
180 #endif // GRAPH_ANALYSIS_BOOST_GRAPH_ARC_ITERATOR_HPP boost::graph_traits< BidirectionalGraph >::vertex_descriptor VertexDescriptor
Definition: DirectedGraph.hpp:31
bool next()
Test if there is a next item and if it is then updates the current to next.
Definition: ArcIterator.hpp:25
Definition: ArcIterator.hpp:98
uint32_t GraphElementId
Definition: GraphElement.hpp:21
OutArcIterator(const T &graph, Vertex::Ptr vertex)
Definition: ArcIterator.hpp:58
bool next()
Test if there is a next item and if it is then updates the current to next.
Definition: ArcIterator.hpp:154
Definition: ArcIterator.hpp:51
bool next()
Test if there is a next item and if it is then updates the current to next.
Definition: ArcIterator.hpp:72
Definition: ArcIterator.hpp:145
InOutArcIterator(const T &graph, Vertex::Ptr vertex)
Definition: ArcIterator.hpp:148
const T & mGraph
Definition: ArcIterator.hpp:173
void setNext(const Edge::Ptr &edge)
Set next edge Should be applied by class implementing next()
Definition: EdgeIterator.hpp:48
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
ArcIterator(const T &graph)
Definition: ArcIterator.hpp:18
OutArcIterator< T > mOutArcIterator
Definition: ArcIterator.hpp:175
Definition: ArcIterator.hpp:12
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
InArcIterator< T > mInArcIterator
Definition: ArcIterator.hpp:174
InArcIterator(const T &graph, Vertex::Ptr vertex)
Definition: ArcIterator.hpp:105
bool skip(const Edge::Ptr &edge) const
Check if edge should be skipped.
Definition: EdgeIterator.cpp:5
bool next()
Test if there is a next item and if it is then updates the current to next.
Definition: ArcIterator.hpp:119
EdgeIterator interface Allows to access all edges of a graph. Requires implementation to wrap the und...
Definition: EdgeIterator.hpp:14