aGrUM  0.14.2
structuralConstraintUndiGraph_inl.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 DOXYGEN_SHOULD_SKIP_THIS
27 
28 namespace gum {
29 
30  namespace learning {
31 
33  INLINE void
34  StructuralConstraintUndiGraph::setGraphAlone(const UndiGraph& graph) {
35  _UndiGraph__graph = graph;
36  }
37 
39  INLINE bool
41  NodeId y) const {
43  && !_UndiGraph__graph.existsEdge(x, y);
44  }
45 
47  INLINE bool
49  NodeId y) const {
50  return _UndiGraph__graph.existsEdge(x, y);
51  }
52 
55  const EdgeAddition& change) const {
56  return checkEdgeAdditionAlone(change.node1(), change.node2());
57  }
58 
61  const EdgeDeletion& change) const {
62  return checkEdgeDeletionAlone(change.node1(), change.node2());
63  }
64 
67  const GraphChange& change) const {
68  switch (change.type()) {
70  return checkEdgeAdditionAlone(change.node1(), change.node2());
71 
73  return checkEdgeDeletionAlone(change.node1(), change.node2());
74 
75  default:
76  GUM_ERROR(OperationNotAllowed,
77  "arc modifications are not "
78  "supported by StructuralConstraintUndiGraph");
79  }
80  }
81 
84  const EdgeAddition& change) {
85  _UndiGraph__graph.addEdge(change.node1(), change.node2());
86  }
87 
90  const EdgeDeletion& change) {
91  _UndiGraph__graph.eraseEdge(Edge(change.node1(), change.node2()));
92  }
93 
95  INLINE void
96  StructuralConstraintUndiGraph::modifyGraphAlone(const GraphChange& change) {
97  switch (change.type()) {
99  modifyGraphAlone(reinterpret_cast< const EdgeAddition& >(change));
100  break;
101 
103  modifyGraphAlone(reinterpret_cast< const EdgeDeletion& >(change));
104  break;
105 
106  default:
107  GUM_ERROR(OperationNotAllowed,
108  "arc modifications are not supported "
109  "by StructuralConstraintUndiGraph");
110  }
111  }
112 
115  const GraphChange&) const {
116  return false;
117  }
118 
120  INLINE void StructuralConstraintUndiGraph::setGraph(Size nb_nodes) {
122  for (NodeId i = 0; i < nb_nodes; ++i) {
124  }
125  }
126 
127 // include all the methods applicable to the whole class hierarchy
128 # define GUM_CONSTRAINT_CLASS_NAME StructuralConstraintUndiGraph
130 # undef GUM_CONSTRAINT_CLASS_NAME
131 
132  } /* namespace learning */
133 
134 } /* namespace gum */
135 
136 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
void setGraphAlone(const UndiGraph &graph)
sets a new graph from which we will perform checkings
virtual void clear()
removes all the nodes and edges from the graph
Definition: undiGraph_inl.h:40
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
UndiGraph _UndiGraph__graph
the UndiGraph on which we perform checks
bool checkModificationAlone(const GraphChange &change) const
checks whether the constraints enable to perform a graph change
virtual void addEdge(const NodeId first, const NodeId second)
insert a new edge into the undirected graph
Definition: undiGraph_inl.h:32
bool isAlwaysInvalidAlone(const GraphChange &change) const
indicates whether a change will always violate the constraint
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
bool existsEdge(const Edge &edge) const
indicates whether a given edge exists
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
void setGraph(Size nb_nodes)
sets a new empty graph from which we will perform checkings
bool checkEdgeDeletionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to remove edge (x,y)
void modifyGraphAlone(const EdgeAddition &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
virtual void eraseEdge(const Edge &edge)
removes an edge from the EdgeGraphPart
Size NodeId
Type for node ids.
Definition: graphElements.h:97
#define GUM_ERROR(type, msg)
Definition: exceptions.h:52
bool checkEdgeAdditionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to add edge (x,y)