aGrUM  0.16.0
structuralConstraintUndiGraph_inl.h
Go to the documentation of this file.
1 
29 #ifndef DOXYGEN_SHOULD_SKIP_THIS
30 
31 namespace gum {
32 
33  namespace learning {
34 
36  INLINE void
37  StructuralConstraintUndiGraph::setGraphAlone(const UndiGraph& graph) {
38  _UndiGraph__graph = graph;
39  }
40 
42  INLINE bool
44  NodeId y) const {
46  && !_UndiGraph__graph.existsEdge(x, y);
47  }
48 
50  INLINE bool
52  NodeId y) const {
53  return _UndiGraph__graph.existsEdge(x, y);
54  }
55 
58  const EdgeAddition& change) const {
59  return checkEdgeAdditionAlone(change.node1(), change.node2());
60  }
61 
64  const EdgeDeletion& change) const {
65  return checkEdgeDeletionAlone(change.node1(), change.node2());
66  }
67 
70  const GraphChange& change) const {
71  switch (change.type()) {
73  return checkEdgeAdditionAlone(change.node1(), change.node2());
74 
76  return checkEdgeDeletionAlone(change.node1(), change.node2());
77 
78  default:
79  GUM_ERROR(OperationNotAllowed,
80  "arc modifications are not "
81  "supported by StructuralConstraintUndiGraph");
82  }
83  }
84 
87  const EdgeAddition& change) {
88  _UndiGraph__graph.addEdge(change.node1(), change.node2());
89  }
90 
93  const EdgeDeletion& change) {
94  _UndiGraph__graph.eraseEdge(Edge(change.node1(), change.node2()));
95  }
96 
98  INLINE void
99  StructuralConstraintUndiGraph::modifyGraphAlone(const GraphChange& change) {
100  switch (change.type()) {
102  modifyGraphAlone(reinterpret_cast< const EdgeAddition& >(change));
103  break;
104 
106  modifyGraphAlone(reinterpret_cast< const EdgeDeletion& >(change));
107  break;
108 
109  default:
110  GUM_ERROR(OperationNotAllowed,
111  "arc modifications are not supported "
112  "by StructuralConstraintUndiGraph");
113  }
114  }
115 
118  const GraphChange&) const {
119  return false;
120  }
121 
123  INLINE void StructuralConstraintUndiGraph::setGraph(Size nb_nodes) {
125  for (NodeId i = 0; i < nb_nodes; ++i) {
127  }
128  }
129 
130 // include all the methods applicable to the whole class hierarchy
131 # define GUM_CONSTRAINT_CLASS_NAME StructuralConstraintUndiGraph
133 # undef GUM_CONSTRAINT_CLASS_NAME
134 
135  } /* namespace learning */
136 
137 } /* namespace gum */
138 
139 #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:43
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:35
bool isAlwaysInvalidAlone(const GraphChange &change) const
indicates whether a change will always violate the constraint
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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:48
virtual void eraseEdge(const Edge &edge)
removes an edge from the EdgeGraphPart
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55
bool checkEdgeAdditionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to add edge (x,y)