graph_analysis
SubGraph.hpp
Go to the documentation of this file.
1 #ifndef GRAPH_ANALYSIS_SUB_GRAPH_HPP
2 #define GRAPH_ANALYSIS_SUB_GRAPH_HPP
3 
4 #include <set>
5 #include "SharedPtr.hpp"
6 #include "VertexIterable.hpp"
7 #include "EdgeIterable.hpp"
8 #include "Filter.hpp"
9 
10 namespace graph_analysis {
11 
12 class BaseGraph;
13 
32 class SubGraph : public VertexIterable, public EdgeIterable
33 {
34 protected:
36  shared_ptr<BaseGraph> mpBaseGraph;
37 
38  std::set<GraphElementId> mDisabledVertices;
39  std::set<GraphElementId> mDisabledEdges;
40 
41 public:
48  SubGraph(const shared_ptr<BaseGraph>& graph);
49 
50  virtual ~SubGraph() {}
51 
52  typedef shared_ptr<SubGraph> Ptr;
53 
59  virtual void enable(const Vertex::Ptr& vertex);
60 
66  virtual void disable(const Vertex::Ptr& vertex);
67 
73  virtual void enable(const Edge::Ptr& edge);
74 
80  virtual void disable(const Edge::Ptr& edge);
81 
86  virtual bool enabled(const Vertex::Ptr& vertex) const;
87 
92  virtual bool enabled(const Edge::Ptr& edge) const;
93 
98  bool disabled(const Vertex::Ptr& vertex) const { return !enabled(vertex); }
99 
104  bool disabled(const Edge::Ptr& edge) const { return !enabled(edge); }
105 
109  void enableAllVertices();
110 
114  void enableAllEdges();
115 
119  void disableAllVertices();
120 
124  void disableAllEdges();
125 
129  void applyFilters(const Filter<Vertex::Ptr>::Ptr& vertexFilter, const Filter<Edge::Ptr>::Ptr& edgeFilter);
130 
135  virtual shared_ptr<BaseGraph> toBaseGraph() const;
136 
141  virtual VertexIterator::Ptr getVertexIterator() const;
142 
147  virtual EdgeIterator::Ptr getEdgeIterator() const;
148 
153  virtual EdgeIterator::Ptr getEdgeIterator(const Vertex::Ptr& vertex) const;
154 
158  shared_ptr<BaseGraph> getBaseGraph() const;
159 };
160 
161 } // end namespace graph_analysis
162 #endif // GRAPH_ANALYSIS_SUB_GRAPH_HPP
Definition: EdgeIterable.hpp:8
virtual shared_ptr< BaseGraph > toBaseGraph() const
Definition: SubGraph.cpp:65
virtual EdgeIterator::Ptr getEdgeIterator() const
Definition: SubGraph.cpp:181
virtual void enable(const Vertex::Ptr &vertex)
Definition: SubGraph.cpp:98
bool disabled(const Edge::Ptr &edge) const
Definition: SubGraph.hpp:104
shared_ptr< BaseGraph > mpBaseGraph
Ptr which refers to the original (super) graph.
Definition: SubGraph.hpp:36
shared_ptr< FilterType > Ptr
Definition: Filter.hpp:59
void disableAllEdges()
Definition: SubGraph.cpp:164
shared_ptr< Edge > Ptr
Definition: Edge.hpp:21
bool disabled(const Vertex::Ptr &vertex) const
Definition: SubGraph.hpp:98
virtual ~SubGraph()
Definition: SubGraph.hpp:50
SubGraph(const shared_ptr< BaseGraph > &graph)
Definition: SubGraph.cpp:10
shared_ptr< BaseGraph > getBaseGraph() const
Definition: SubGraph.cpp:92
void disableAllVertices()
Definition: SubGraph.cpp:158
std::set< GraphElementId > mDisabledEdges
Definition: SubGraph.hpp:39
void enableAllVertices()
Definition: SubGraph.cpp:146
virtual void disable(const Vertex::Ptr &vertex)
Definition: SubGraph.cpp:109
Main namespace of the graph analysis library.
Definition: BFS.cpp:3
shared_ptr< Vertex > Ptr
Definition: Vertex.hpp:22
shared_ptr< EdgeIterator > Ptr
Definition: EdgeIterator.hpp:20
A subgraph represent a particular filtered &#39;view&#39; on a BaseGraph.
Definition: SubGraph.hpp:32
virtual bool enabled(const Vertex::Ptr &vertex) const
Definition: SubGraph.cpp:130
shared_ptr< SubGraph > Ptr
Definition: SubGraph.hpp:52
shared_ptr< VertexIterator > Ptr
Definition: VertexIterator.hpp:21
void enableAllEdges()
Definition: SubGraph.cpp:152
void applyFilters(const Filter< Vertex::Ptr >::Ptr &vertexFilter, const Filter< Edge::Ptr >::Ptr &edgeFilter)
Definition: SubGraph.cpp:18
std::set< GraphElementId > mDisabledVertices
Definition: SubGraph.hpp:38
virtual VertexIterator::Ptr getVertexIterator() const
Definition: SubGraph.cpp:170
Definition: VertexIterable.hpp:8