aGrUM  0.20.2
a C++ library for (probabilistic) graphical models
graphChange.cpp
Go to the documentation of this file.
1 /**
2  *
3  * Copyright 2005-2020 Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /** @file
23  * @brief A class to account for changes in a graph
24  *
25  * This class shall be used by learning algorithms to notify scores, structural
26  * constraints, etc, that the learnt graph has been modified.
27  *
28  * @author Christophe GONZALES(@AMU) and Pierre-Henri WUILLEMIN(@LIP6)
29  */
30 
31 #include <agrum/BN/learning/structureUtils/graphChange.h>
32 
33 #ifdef GUM_NO_INLINE
34 # include <agrum/BN/learning/structureUtils/graphChange_inl.h>
35 #endif // GUM_NOINLINE
36 
37 namespace gum {
38 
39  namespace learning {
40 
41  /// put the content of the GraphChange into a string
44  switch (type()) {
46  stream << "ArcAddition ( " << node1() << " , " << node2() << " )";
47  return stream.str();
48 
50  stream << "ArcDeletion ( " << node1() << " , " << node2() << " )";
51  return stream.str();
52 
54  stream << "ArcReversal ( " << node1() << " , " << node2() << " )";
55  return stream.str();
56 
58  stream << "EdgeAddition ( " << node1() << " , " << node2() << " )";
59  return stream.str();
60 
62  stream << "EdgeDeletion ( " << node1() << " , " << node2() << " )";
63  return stream.str();
64 
65  default:
67  "this graph modification is not supported yet");
68  }
69  }
70 
71  /// put the content of the ArcAddition into a string
74  stream << "ArcAddition ( " << node1() << " , " << node2() << " )";
75  return stream.str();
76  }
77 
78  /// put the content of the ArcDeletion into a string
81  stream << "ArcDeletion ( " << node1() << " , " << node2() << " )";
82  return stream.str();
83  }
84 
85  /// put the content of the ArcReversal into a string
88  stream << "ArcReversal ( " << node1() << " , " << node2() << " )";
89  return stream.str();
90  }
91 
92  /// put the content of the EdgeAddition into a string
95  stream << "EdgeAddition ( " << node1() << " , " << node2() << " )";
96  return stream.str();
97  }
98 
99  /// put the content of the EdgeDeletion into a string
102  stream << "EdgeDeletion ( " << node1() << " , " << node2() << " )";
103  return stream.str();
104  }
105 
106  /// a \c << operator for GraphChanges
108  return stream << change.toString();
109  }
110 
111  /// a \c << operator for ArcAddition
113  return stream << change.toString();
114  }
115 
116  /// a \c << operator for ArcDeletion
118  return stream << change.toString();
119  }
120 
121  /// a \c << operator for ArcReversal
123  return stream << change.toString();
124  }
125 
126  /// a \c << operator for EdgeAddition
128  return stream << change.toString();
129  }
130 
131  /// a \c << operator for EdgeDeletion
133  return stream << change.toString();
134  }
135 
136  } /* namespace learning */
137 
138 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:669
std::ostream & operator<<(std::ostream &stream, const EdgeDeletion &change)
a << operator for EdgeDeletion
Database(const std::string &filename, const BayesNet< GUM_SCALAR > &bn, const std::vector< std::string > &missing_symbols)