aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
graphChange.cpp
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by 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:
66  GUM_ERROR(OperationNotAllowed, "this graph modification is not supported yet")
67  }
68  }
69 
70  /// put the content of the ArcAddition into a string
73  stream << "ArcAddition ( " << node1() << " , " << node2() << " )";
74  return stream.str();
75  }
76 
77  /// put the content of the ArcDeletion into a string
80  stream << "ArcDeletion ( " << node1() << " , " << node2() << " )";
81  return stream.str();
82  }
83 
84  /// put the content of the ArcReversal into a string
87  stream << "ArcReversal ( " << node1() << " , " << node2() << " )";
88  return stream.str();
89  }
90 
91  /// put the content of the EdgeAddition into a string
94  stream << "EdgeAddition ( " << node1() << " , " << node2() << " )";
95  return stream.str();
96  }
97 
98  /// put the content of the EdgeDeletion into a string
101  stream << "EdgeDeletion ( " << node1() << " , " << node2() << " )";
102  return stream.str();
103  }
104 
105  /// a \c << operator for GraphChanges
107  return stream << change.toString();
108  }
109 
110  /// a \c << operator for ArcAddition
112  return stream << change.toString();
113  }
114 
115  /// a \c << operator for ArcDeletion
117  return stream << change.toString();
118  }
119 
120  /// a \c << operator for ArcReversal
122  return stream << change.toString();
123  }
124 
125  /// a \c << operator for EdgeAddition
127  return stream << change.toString();
128  }
129 
130  /// a \c << operator for EdgeDeletion
132  return stream << change.toString();
133  }
134 
135  } /* namespace learning */
136 
137 } /* namespace gum */
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
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)