aGrUM  0.14.2
graphChange.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
30 
31 #ifdef GUM_NO_INLINE
33 #endif // GUM_NOINLINE
34 
35 namespace gum {
36 
37  namespace learning {
38 
40  std::string GraphChange::toString() const {
41  std::stringstream stream;
42  switch (type()) {
44  stream << "ArcAddition ( " << node1() << " , " << node2() << " )";
45  return stream.str();
46 
48  stream << "ArcDeletion ( " << node1() << " , " << node2() << " )";
49  return stream.str();
50 
52  stream << "ArcReversal ( " << node1() << " , " << node2() << " )";
53  return stream.str();
54 
56  stream << "EdgeAddition ( " << node1() << " , " << node2() << " )";
57  return stream.str();
58 
60  stream << "EdgeDeletion ( " << node1() << " , " << node2() << " )";
61  return stream.str();
62 
63  default:
65  "this graph modification is not supported yet");
66  }
67  }
68 
70  std::string ArcAddition::toString() const {
71  std::stringstream stream;
72  stream << "ArcAddition ( " << node1() << " , " << node2() << " )";
73  return stream.str();
74  }
75 
77  std::string ArcDeletion::toString() const {
78  std::stringstream stream;
79  stream << "ArcDeletion ( " << node1() << " , " << node2() << " )";
80  return stream.str();
81  }
82 
84  std::string ArcReversal::toString() const {
85  std::stringstream stream;
86  stream << "ArcReversal ( " << node1() << " , " << node2() << " )";
87  return stream.str();
88  }
89 
91  std::string EdgeAddition::toString() const {
92  std::stringstream stream;
93  stream << "EdgeAddition ( " << node1() << " , " << node2() << " )";
94  return stream.str();
95  }
96 
98  std::string EdgeDeletion::toString() const {
99  std::stringstream stream;
100  stream << "EdgeDeletion ( " << node1() << " , " << node2() << " )";
101  return stream.str();
102  }
103 
105  std::ostream& operator<<(std::ostream& stream, const GraphChange& change) {
106  return stream << change.toString();
107  }
108 
110  std::ostream& operator<<(std::ostream& stream, const ArcAddition& change) {
111  return stream << change.toString();
112  }
113 
115  std::ostream& operator<<(std::ostream& stream, const ArcDeletion& change) {
116  return stream << change.toString();
117  }
118 
120  std::ostream& operator<<(std::ostream& stream, const ArcReversal& change) {
121  return stream << change.toString();
122  }
123 
125  std::ostream& operator<<(std::ostream& stream, const EdgeAddition& change) {
126  return stream << change.toString();
127  }
128 
130  std::ostream& operator<<(std::ostream& stream, const EdgeDeletion& change) {
131  return stream << change.toString();
132  }
133 
134  } /* namespace learning */
135 
136 } /* namespace gum */
the classes to account for structure changes in a graph
The class for notifying learning algorithms of new arc additionsThis class is convenient to know at c...
Definition: graphChange.h:147
The class for notifying learning algorithms of arc removalsThis class is convenient to know at compil...
Definition: graphChange.h:213
std::ostream & operator<<(std::ostream &stream, const IdSet< ALLOC > &idset)
the display operator
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
A class to account for changes in a graph.
The class for notifying learning algorithms of edge removalsThis class is convenient to know at compi...
Definition: graphChange.h:411
virtual std::string toString() const final
put the content of the EdgeAddition into a string
Definition: graphChange.cpp:91
virtual std::string toString() const final
put the content of the EdgeDeletion into a string
Definition: graphChange.cpp:98
The class for notifying learning algorithms of new edge additionsThis class is convenient to know at ...
Definition: graphChange.h:345
GraphChangeType type() const noexcept
returns the type of the operation
NodeId node2() const noexcept
returns the second node involved in the modification
virtual std::string toString() const final
put the content of the ArcReversal into a string
Definition: graphChange.cpp:84
virtual std::string toString() const
put the content of the graph change into a string
Definition: graphChange.cpp:40
The class for notifying learning algorithms of arc reversalsThis class is convenient to know at compi...
Definition: graphChange.h:279
virtual std::string toString() const final
put the content of the ArcDeletion into a string
Definition: graphChange.cpp:77
virtual std::string toString() const final
put the content of the ArcAddition into a string
Definition: graphChange.cpp:70
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
NodeId node1() const noexcept
returns the first node involved in the modification