aGrUM  0.16.0
graphChange.h
Go to the documentation of this file.
1 
32 #ifndef GUM_LEARNING_GRAPH_CHANGE_H
33 #define GUM_LEARNING_GRAPH_CHANGE_H
34 
35 #include <iostream>
36 #include <string>
37 
38 #include <agrum/agrum.h>
39 #include <agrum/core/hashFunc.h>
41 
42 namespace gum {
43 
44  namespace learning {
45 
53  };
54 
55  /* =========================================================================
56  */
57  /* === GRAPH CHANGE CLASS ===
58  */
59  /* =========================================================================
60  */
65  class GraphChange {
66  public:
67  // ##########################################################################
69  // ##########################################################################
71 
74 
76  GraphChange(const GraphChange& from) noexcept;
77 
79  GraphChange(GraphChange&& from) noexcept;
80 
82  ~GraphChange() noexcept;
83 
85 
86  // ##########################################################################
88  // ##########################################################################
90 
92  GraphChange& operator=(const GraphChange& from) noexcept;
93 
95  GraphChange& operator=(GraphChange&& from) noexcept;
96 
98  bool operator==(const GraphChange& from) const noexcept;
99 
101  bool operator!=(const GraphChange& from) const noexcept;
102 
104 
105  // ##########################################################################
107  // ##########################################################################
109 
111  GraphChangeType type() const noexcept;
112 
114  NodeId node1() const noexcept;
115 
117  NodeId node2() const noexcept;
118 
120  virtual std::string toString() const;
121 
123 
124  private:
127 
130 
133  };
134 
135  /* =========================================================================
136  */
137  /* === ARC ADDITION CLASS ===
138  */
139  /* =========================================================================
140  */
150  class ArcAddition : public GraphChange {
151  public:
152  // ##########################################################################
154  // ##########################################################################
156 
158  ArcAddition(NodeId node1, NodeId node2) noexcept;
159 
161  ArcAddition(const ArcAddition& from) noexcept;
162 
164  ArcAddition(ArcAddition&& from) noexcept;
165 
167  ~ArcAddition() noexcept;
168 
170 
171  // ##########################################################################
173  // ##########################################################################
175 
177  ArcAddition& operator=(const ArcAddition& from) noexcept;
178 
180  ArcAddition& operator=(ArcAddition&& from) noexcept;
181 
183  bool operator==(const ArcAddition& from) const noexcept;
184 
186  bool operator!=(const ArcAddition& from) const noexcept;
187 
189 
190  // ##########################################################################
192  // ##########################################################################
194 
196  virtual std::string toString() const final;
197 
199  };
200 
201  /* =========================================================================
202  */
203  /* === ARC DELETION CLASS ===
204  */
205  /* =========================================================================
206  */
216  class ArcDeletion : public GraphChange {
217  public:
218  // ##########################################################################
220  // ##########################################################################
222 
224  ArcDeletion(NodeId node1, NodeId node2) noexcept;
225 
227  ArcDeletion(const ArcDeletion& from) noexcept;
228 
230  ArcDeletion(ArcDeletion&& from) noexcept;
231 
233  ~ArcDeletion() noexcept;
234 
236 
237  // ##########################################################################
239  // ##########################################################################
241 
243  ArcDeletion& operator=(const ArcDeletion& from) noexcept;
244 
246  ArcDeletion& operator=(ArcDeletion&& from) noexcept;
247 
249  bool operator==(const ArcDeletion& from) const noexcept;
250 
252  bool operator!=(const ArcDeletion& from) const noexcept;
253 
255 
256  // ##########################################################################
258  // ##########################################################################
260 
262  virtual std::string toString() const final;
263 
265  };
266 
267  /* =========================================================================
268  */
269  /* === ARC REVERSAL CLASS ===
270  */
271  /* =========================================================================
272  */
282  class ArcReversal : public GraphChange {
283  public:
284  // ##########################################################################
286  // ##########################################################################
288 
290  ArcReversal(NodeId node1, NodeId node2) noexcept;
291 
293  ArcReversal(const ArcReversal& from) noexcept;
294 
296  ArcReversal(ArcReversal&& from) noexcept;
297 
299  ~ArcReversal() noexcept;
300 
302 
303  // ##########################################################################
305  // ##########################################################################
307 
309  ArcReversal& operator=(const ArcReversal& from) noexcept;
310 
312  ArcReversal& operator=(ArcReversal&& from) noexcept;
313 
315  bool operator==(const ArcReversal& from) const noexcept;
316 
318  bool operator!=(const ArcReversal& from) const noexcept;
319 
321 
322  // ##########################################################################
324  // ##########################################################################
326 
328  virtual std::string toString() const final;
329 
331  };
332 
333  /* =========================================================================
334  */
335  /* === EDGE ADDITION CLASS ===
336  */
337  /* =========================================================================
338  */
348  class EdgeAddition : public GraphChange {
349  public:
350  // ##########################################################################
352  // ##########################################################################
354 
356  EdgeAddition(NodeId node1, NodeId node2) noexcept;
357 
359  EdgeAddition(const EdgeAddition& from) noexcept;
360 
362  EdgeAddition(EdgeAddition&& from) noexcept;
363 
365  ~EdgeAddition() noexcept;
366 
368 
369  // ##########################################################################
371  // ##########################################################################
373 
375  EdgeAddition& operator=(const EdgeAddition& from) noexcept;
376 
378  EdgeAddition& operator=(EdgeAddition&& from) noexcept;
379 
381  bool operator==(const EdgeAddition& from) const noexcept;
382 
384  bool operator!=(const EdgeAddition& from) const noexcept;
385 
387 
388  // ##########################################################################
390  // ##########################################################################
392 
394  virtual std::string toString() const final;
395 
397  };
398 
399  /* =========================================================================
400  */
401  /* === EDGE DELETION CLASS ===
402  */
403  /* =========================================================================
404  */
414  class EdgeDeletion : public GraphChange {
415  public:
416  // ##########################################################################
418  // ##########################################################################
420 
422  EdgeDeletion(NodeId node1, NodeId node2) noexcept;
423 
425  EdgeDeletion(const EdgeDeletion& from) noexcept;
426 
428  EdgeDeletion(EdgeDeletion&& from) noexcept;
429 
431  ~EdgeDeletion() noexcept;
432 
434 
435  // ##########################################################################
437  // ##########################################################################
439 
441  EdgeDeletion& operator=(const EdgeDeletion& from) noexcept;
442 
444  EdgeDeletion& operator=(EdgeDeletion&& from) noexcept;
445 
447  bool operator==(const EdgeDeletion& from) const noexcept;
448 
450  bool operator!=(const EdgeDeletion& from) const noexcept;
451 
453 
454  // ##########################################################################
456  // ##########################################################################
458 
460  virtual std::string toString() const final;
461 
463  };
464 
466  std::ostream& operator<<(std::ostream& stream, const GraphChange& change);
467 
469  std::ostream& operator<<(std::ostream& stream, const ArcAddition& change);
470 
472  std::ostream& operator<<(std::ostream& stream, const ArcDeletion& change);
473 
475  std::ostream& operator<<(std::ostream& stream, const ArcReversal& change);
476 
478  std::ostream& operator<<(std::ostream& stream, const EdgeAddition& change);
479 
481  std::ostream& operator<<(std::ostream& stream, const EdgeDeletion& change);
482 
483  } /* namespace learning */
484 
486  template <>
487  class HashFunc< learning::GraphChange >
488  : public HashFuncBase< learning::GraphChange > {
489  public:
495  static Size castToSize(const learning::GraphChange& key);
496 
498  virtual Size operator()(const learning::GraphChange& key) const override final;
499  };
500 
502  template <>
503  class HashFunc< learning::ArcAddition >
504  : public HashFuncBase< learning::ArcAddition > {
505  public:
511  static Size castToSize(const learning::ArcAddition& key);
512 
514  virtual Size operator()(const learning::ArcAddition& key) const override final;
515  };
516 
518  template <>
519  class HashFunc< learning::ArcDeletion >
520  : public HashFuncBase< learning::ArcDeletion > {
521  public:
527  static Size castToSize(const learning::ArcDeletion& key);
528 
530  virtual Size operator()(const learning::ArcDeletion& key) const override final;
531  };
532 
534  template <>
535  class HashFunc< learning::ArcReversal >
536  : public HashFuncBase< learning::ArcReversal > {
537  public:
543  static Size castToSize(const learning::ArcReversal& key);
544 
546  virtual Size operator()(const learning::ArcReversal& key) const override final;
547  };
548 
550  template <>
551  class HashFunc< learning::EdgeAddition >
552  : public HashFuncBase< learning::EdgeAddition > {
558  static Size castToSize(const learning::EdgeAddition& key);
559 
561  virtual Size
562  operator()(const learning::EdgeAddition& key) const override final;
563  };
564 
566  template <>
567  class HashFunc< learning::EdgeDeletion >
568  : public HashFuncBase< learning::EdgeDeletion > {
569  public:
575  static Size castToSize(const learning::EdgeDeletion& key);
576 
578  virtual Size
579  operator()(const learning::EdgeDeletion& key) const override final;
580  };
581 
582 } /* namespace gum */
583 
584 #ifndef GUM_NO_INLINE
586 #endif // GUM_NOINLINE
587 
588 #endif /* GUM_LEARNING_GRAPH_CHANGE_H */
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for notifying learning algorithms of new arc additionsThis class is convenient to know at c...
Definition: graphChange.h:150
The class for notifying learning algorithms of arc removalsThis class is convenient to know at compil...
Definition: graphChange.h:216
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
std::ostream & operator<<(std::ostream &stream, const IdSet< ALLOC > &idset)
the display operator
Class template representing hashing function of LpCol.
Definition: hashFunc.h:471
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
NodeId __node2
the second node in the edge or arc to be modified
Definition: graphChange.h:132
~GraphChange() noexcept
destructor
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for notifying learning algorithms of edge removalsThis class is convenient to know at compi...
Definition: graphChange.h:414
GraphChange & operator=(const GraphChange &from) noexcept
copy constructor
bool operator==(const GraphChange &from) const noexcept
returns whether two graph changes are identical or not
The class for notifying learning algorithms of new edge additionsThis class is convenient to know at ...
Definition: graphChange.h:348
GraphChangeType type() const noexcept
returns the type of the operation
GraphChangeType __type
the type of modification
Definition: graphChange.h:126
NodeId node2() const noexcept
returns the second node involved in the modification
virtual std::string toString() const
put the content of the graph change into a string
Definition: graphChange.cpp:43
NodeId __node1
the first node in the edge or arc to be modified
Definition: graphChange.h:129
bool operator!=(const GraphChange &from) const noexcept
returns whether two graph changes are different or not
The class for notifying learning algorithms of arc reversalsThis class is convenient to know at compi...
Definition: graphChange.h:282
GraphChangeType
the type of modification that can be applied to the graph
Definition: graphChange.h:47
All hash functions should inherit from this class.
Definition: hashFunc.h:149
GraphChange(GraphChangeType type, NodeId node1, NodeId node2) noexcept
default constructor
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
Size NodeId
Type for node ids.
Definition: graphElements.h:98
NodeId node1() const noexcept
returns the first node involved in the modification