aGrUM  0.14.2
structuralConstraintIndegree.h
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  ***************************************************************************/
26 #ifndef GUM_LEARNING_STRUCTURAL_CONSTRAINT_INDEGREE_H
27 #define GUM_LEARNING_STRUCTURAL_CONSTRAINT_INDEGREE_H
28 
29 #include <limits>
30 
31 #include <agrum/agrum.h>
34 
35 namespace gum {
36 
37  namespace learning {
38 
47  : protected virtual StructuralConstraintSetStatic<
48  StructuralConstraintDiGraph > {
49  public:
50  // ##########################################################################
52  // ##########################################################################
54 
57 
59  StructuralConstraintIndegree(Size nb_nodes, Size max_indegree);
60 
62  StructuralConstraintIndegree(const DiGraph& graph, Size max_indegree);
63 
66 
69 
72 
74 
75  // ##########################################################################
77  // ##########################################################################
79 
83 
86 
88 
89  // ##########################################################################
91  // ##########################################################################
93 
95  void setIndegree(const NodeProperty< Size >& max_indegree);
96 
99  void setMaxIndegree(Size max_indegree, bool update_all_node = false);
100 
102  void setGraphAlone(const DiGraph& graph);
103 
105 
111  void modifyGraphAlone(const ArcAddition& change);
112 
114 
116  void modifyGraphAlone(const ArcDeletion& change);
117 
119 
125  void modifyGraphAlone(const ArcReversal& change);
126 
128 
134  void modifyGraphAlone(const GraphChange& change);
135 
137 
150  bool isAlwaysInvalidAlone(const GraphChange& change) const;
151 
153 
156  bool checkArcAdditionAlone(NodeId x, NodeId y) const;
157 
159 
160  bool checkArcDeletionAlone(NodeId x, NodeId y) const;
161 
163 
166  bool checkArcReversalAlone(NodeId x, NodeId y) const;
167 
169 
172  bool checkModificationAlone(const ArcAddition& change) const;
173 
175 
176  bool checkModificationAlone(const ArcDeletion& change) const;
177 
179 
182  bool checkModificationAlone(const ArcReversal& change) const;
183 
185 
192  bool checkModificationAlone(const GraphChange& change) const;
193 
195 
196 #ifndef DOXYGEN_SHOULD_SKIP_THIS
197 // include the set of methods that enable the structural constraint to
198 // be standalone, i.e., that it needs not be included into a
199 // StructuralConstraintSetStatic to be used by learning algorithms
200 # define GUM_CONSTRAINT_CLASS_NAME StructuralConstraintIndegree
202 # undef GUM_CONSTRAINT_CLASS_NAME
203 #endif // DOXYGEN_SHOULD_SKIP_THIS
204 
205  protected:
208 
210  Size _Indegree__max_indegree{std::numeric_limits< Size >::max()};
211  };
212 
213  } /* namespace learning */
214 
215 } /* namespace gum */
216 
218 #ifndef GUM_NO_INLINE
220 #endif /* GUM_NO_INLINE */
221 
222 #endif /* GUM_LEARNING_STRUCTURAL_CONSTRAINT_INDEGREE_H */
void setIndegree(const NodeProperty< Size > &max_indegree)
sets the default max indegree for all the nodes in the property
the class for structural constraints limiting the number of parents of nodes in a directed graph ...
bool checkModificationAlone(const ArcAddition &change) const
checks whether the constraints enable to add an arc
The class for notifying learning algorithms of new arc additionsThis class is convenient to know at c...
Definition: graphChange.h:147
void setMaxIndegree(Size max_indegree, bool update_all_node=false)
resets the default max indegree and possibly updates the indegree of all nodes
The class for notifying learning algorithms of arc removalsThis class is convenient to know at compil...
Definition: graphChange.h:213
bool isAlwaysInvalidAlone(const GraphChange &change) const
indicates whether a change will always violate the constraint
the "meta-programming" class for storing several structural constraints
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
The class for generic Hash Tables.
Definition: hashTable.h:676
Size _Indegree__max_indegree
a default max indegree to assign for nodes without specified indegree
the base class for structural constraints used by learning algorithms that learn a directed graph str...
the "meta-programming" class for storing structural constraintsIn aGrUM, there are two ways to store ...
bool checkArcDeletionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to remove arc (x,y)
bool checkArcAdditionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to add arc (x,y)
Base class for all oriented graphs.
Definition: diGraph.h:108
the class for structural constraints limiting the number of parents of nodes in a directed graph ...
NodeProperty< Size > _Indegree__max_parents
the max number of parents per node
The class for notifying learning algorithms of arc reversalsThis class is convenient to know at compi...
Definition: graphChange.h:279
void modifyGraphAlone(const ArcAddition &change)
notify the constraint of a modification of the graph
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
void setGraphAlone(const DiGraph &graph)
sets a new graph from which we will perform checkings
StructuralConstraintIndegree & operator=(const StructuralConstraintIndegree &from)
copy operator
Size NodeId
Type for node ids.
Definition: graphElements.h:97
bool checkArcReversalAlone(NodeId x, NodeId y) const
checks whether the constraints enable to reverse arc (x,y)