graph_analysis
NodeIterator.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_LEMON_NODE_ITERATOR_HPP
2 #define GRAPH_ANALYSIS_LEMON_NODE_ITERATOR_HPP
3 
4 #include "../VertexIterator.hpp"
5 #include <lemon/core.h>
6 
7 namespace graph_analysis {
8 namespace lemon {
9 
10 template<typename T>
12 {
13 public:
14  NodeIterator(const T& graph)
15  : mGraph(graph)
16  , mNodeIt(graph.raw())
17  {}
18 
19  bool next()
20  {
21  while( mNodeIt != ::lemon::INVALID)
22  {
23  Vertex::Ptr vertex = mGraph.mVertexMap[mNodeIt];
24  ++mNodeIt;
25  if(skip(vertex))
26  {
27  continue;
28  }
29  setNext(vertex);
30  return true;
31  }
32  return false;
33  }
34 
35 protected:
36  const T& mGraph;
37  typename T::graph_t::NodeIt mNodeIt;
38 
39 };
40 
41 } // end namespace lemon
42 } // end namespace graph_analysis
43 #endif // GRAPH_ANALYSIS_LEMON_NODE_ITERATOR_HPP
VertexIterator interface Allows to access all vertices of a graph. Requires implementation to wrap th...
Definition: VertexIterator.hpp:15
bool next()
Test if there is a next item and if it is then updates the current to next.
Definition: NodeIterator.hpp:19
bool skip(const Vertex::Ptr &vertex) const
Definition: VertexIterator.cpp:5
T::graph_t::NodeIt mNodeIt
Definition: NodeIterator.hpp:37
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
Definition: NodeIterator.hpp:11
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
NodeIterator(const T &graph)
Definition: NodeIterator.hpp:14
const T & mGraph
Definition: NodeIterator.hpp:36
void setNext(const Vertex::Ptr &vertex)
Set next vertex Should be applied by class implementing next()
Definition: VertexIterator.hpp:49