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