DiaDes  0.1
DIAgnosis of Discrete-Event System
GraphNodeSet.hh
Go to the documentation of this file.
1 #ifndef __DIADES__GRAPH__GRAPHNODESET__HH
2 #define __DIADES__GRAPH__GRAPHNODESET__HH
3 
4 #include <set>
5 #include <unordered_set>
6 //#include <boost/archive/text_oarchive.hpp>
7 //#include <boost/archive/text_iarchive.hpp>
10 #include <diades/graph/Graph.hh>
11 
12 
13 
14 using namespace std;
15 
16 
17 
18 namespace Diades
19 {
20  namespace Graph
21  {
22 
31  {
32  public:
34  static string
36  {
37  return "Graph::GraphNodeSet";
38  }
41  using Iterator = set<Node>::const_iterator;
42  protected:
43 
44  const Graph & _grph;
45 
46  // template<class Archive>
47  // void serialize(Archive & ar, const unsigned int version)
48  // {
49  // ar & const_cast<Graph *>(_grph);
50  // ar & _nodes;
51  // }
52 
53  protected:
54  set<Node> _nodes;
55 
56 
57 
58 
59  public:
60 
65  GraphNodeSet(const Graph & graph) : _grph(graph), _nodes()
66  {
67  }
68 
76  GraphNodeSet(const Graph & graph, Node n);
77 
85  GraphNodeSet(const Graph & graph, const set<Node> & n);
86 
87 
88 
96  GraphNodeSet(const Graph & graph, const unordered_set<Node> & s);
97 
98 
99 
100 
103  GraphNodeSet(const GraphNodeSet & ns);
104 
105 
106 
107 
108 
109 
115  void insertNode(Node n);
116 
117  template<class InputNodeIterator>
118  void
119  insertNodes(InputNodeIterator first, InputNodeIterator last)
120  {
121  _nodes.insert(first, last);
122  }
123 
129  void removeNode(Node n);
130 
136  Iterator
137  findNode(Node n) const
138  {
139  require(Exception, n.valid(), "findNode: the node n is invalid.");
140  require(Exception, &n.owner() == &_grph, "findNode: the node n has an incorrect owner.");
141  return _nodes.find(n);
142  }
143 
148  bool
149  isEmpty() const
150  {
151  return _nodes.empty();
152  }
153 
157  int
158  size() const
159  {
160  return _nodes.size();
161  }
162 
163 
170  GraphNodeSet * nextGraphNodeSet(const set<Edge> & edges) const;
171 
172 
180  GraphNodeSet * previousGraphNodeSet(const set<Edge> & edges) const;
181 
186  const Graph &
187  graph() const
188  {
189  return _grph;
190  }
191 
195  Iterator
196  begin() const
197  {
198  return _nodes.begin();
199  }
200 
204  Iterator
205  end() const
206  {
207  return _nodes.end();
208  }
209 
213  set<Node> &
215  {
216  return _nodes;
217  }
218 
223  bool operator==(const GraphNodeSet & ns) const
224  {
225  return(&_grph == &ns._grph) && (_nodes == ns._nodes);
226  }
227 
229  friend ostream & operator<<(ostream & os, const GraphNodeSet & s);
230 
231 
232  };
233 
234 
235  };
236 };
237 #endif
STL namespace.
bool operator==(const GraphNodeSet &ns) const
GraphNodeSet(const Graph &graph)
Definition: GraphNodeSet.hh:65
Diades::Graph::Node Node
Definition: GraphNodeSet.hh:33
Iterator findNode(Node n) const
#define require(Exception, expr, message)
Definition: Assertion.hh:90
Namespace of the Diades project.
std::ostream & operator<<(std::ostream &os, const Identifier &identifier)
Definition: Identifier.hh:501
ConstIterator on the Net.
boost::adjacency_list Graph
Definition: ScaleFree.cc:9
void insertNodes(InputNodeIterator first, InputNodeIterator last)
const Graph & graph() const