aGrUM  0.14.2
structuralConstraintPattern4UndiGraphInline.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  ***************************************************************************/
20 
21 // this file should be included at the end of the StructuralConstraints inline
22 // files (see StructuralConstraintDegree to see how it should be included).
23 // This concerns only StructuralConstraints that derive from other
24 // StructuralConstraints. If your class does not derive from anoter constraint,
25 // include file StructuralConstraintPattern4UndiGraphRootInline.h instead.
26 
27 #ifdef GUM_CONSTRAINT_CLASS_NAME
28 
30 INLINE void GUM_CONSTRAINT_CLASS_NAME::setGraph(const UndiGraph& graph) {
31  constraints::setGraph(graph);
32  setGraphAlone(graph);
33 }
34 
36 INLINE bool GUM_CONSTRAINT_CLASS_NAME::checkEdgeAddition(NodeId x,
37  NodeId y) const {
38  return constraints::checkEdgeAddition(x, y) && checkEdgeAdditionAlone(x, y);
39 }
40 
42 INLINE bool GUM_CONSTRAINT_CLASS_NAME::checkEdgeDeletion(NodeId x,
43  NodeId y) const {
44  return constraints::checkEdgeDeletion(x, y) && checkEdgeDeletionAlone(x, y);
45 }
46 
48 INLINE void GUM_CONSTRAINT_CLASS_NAME::modifyGraph(const EdgeAddition& change) {
49  constraints::modifyGraph(change);
50  modifyGraphAlone(change);
51 }
52 
54 INLINE void GUM_CONSTRAINT_CLASS_NAME::modifyGraph(const EdgeDeletion& change) {
55  constraints::modifyGraph(change);
56  modifyGraphAlone(change);
57 }
58 
60 INLINE void GUM_CONSTRAINT_CLASS_NAME::modifyGraph(const GraphChange& change) {
61  constraints::modifyGraph(change);
62  modifyGraphAlone(change);
63 }
64 
66 INLINE bool GUM_CONSTRAINT_CLASS_NAME::isAlwaysInvalid(const GraphChange&) const {
67  return constraints::isAlwaysInvalid(change) || isAlwaysInvalidAlone(change);
68 }
69 
71 INLINE bool
72  GUM_CONSTRAINT_CLASS_NAME::checkModification(const EdgeAddition& change) const {
73  return checkEdgeAddition(change.node1(), change.node2());
74 }
75 
77 INLINE bool
78  GUM_CONSTRAINT_CLASS_NAME::checkModification(const EdgeDeletion& change) const {
79  return checkEdgeDeletion(change.node1(), change.node2());
80 }
81 
83 INLINE bool
84  GUM_CONSTRAINT_CLASS_NAME::checkModification(const GraphChange& change) const {
85  switch (change.type()) {
87  return checkEdgeAddition(change.node1(), change.node2());
88 
90  return checkEdgeDeletion(change.node1(), change.node2());
91 
92  default:
93  GUM_ERROR(OperationNotAllowed,
94  "arc modifications are not supported by the constraint");
95  }
96 }
97 
98 #endif /* GUM_CONSTRAINT_CLASS_NAME */
Size NodeId
Type for node ids.
Definition: graphElements.h:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52