aGrUM  0.16.0
structuralConstraintDiGraph_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 StructuralConstraintDiGraph::setGraphAlone(const DiGraph& graph) {
37  _DiGraph__graph = graph;
38  }
39 
41  INLINE bool
43  NodeId y) const {
45  && !_DiGraph__graph.existsArc(x, y);
46  }
47 
49  INLINE bool
51  NodeId y) const {
52  return _DiGraph__graph.existsArc(x, y);
53  }
54 
56  INLINE bool
58  NodeId y) const {
59  return _DiGraph__graph.existsArc(x, y) && !_DiGraph__graph.existsArc(y, x);
60  }
61 
64  const ArcAddition& change) const {
65  return checkArcAdditionAlone(change.node1(), change.node2());
66  }
67 
70  const ArcDeletion& change) const {
71  return checkArcDeletionAlone(change.node1(), change.node2());
72  }
73 
76  const ArcReversal& change) const {
77  return checkArcReversalAlone(change.node1(), change.node2());
78  }
79 
82  const GraphChange& change) const {
83  switch (change.type()) {
85  return checkArcAdditionAlone(change.node1(), change.node2());
86 
88  return checkArcDeletionAlone(change.node1(), change.node2());
89 
91  return checkArcReversalAlone(change.node1(), change.node2());
92 
93  default:
94  GUM_ERROR(OperationNotAllowed,
95  "edge modifications are not "
96  "supported by StructuralConstraintDiGraph");
97  }
98  }
99 
101  INLINE void
102  StructuralConstraintDiGraph::modifyGraphAlone(const ArcAddition& change) {
103  _DiGraph__graph.addArc(change.node1(), change.node2());
104  }
105 
107  INLINE void
108  StructuralConstraintDiGraph::modifyGraphAlone(const ArcDeletion& change) {
109  _DiGraph__graph.eraseArc(Arc(change.node1(), change.node2()));
110  }
111 
113  INLINE void
114  StructuralConstraintDiGraph::modifyGraphAlone(const ArcReversal& change) {
115  _DiGraph__graph.eraseArc(Arc(change.node1(), change.node2()));
116  _DiGraph__graph.addArc(change.node2(), change.node1());
117  }
118 
120  INLINE void
121  StructuralConstraintDiGraph::modifyGraphAlone(const GraphChange& change) {
122  switch (change.type()) {
124  modifyGraphAlone(reinterpret_cast< const ArcAddition& >(change));
125  break;
126 
128  modifyGraphAlone(reinterpret_cast< const ArcDeletion& >(change));
129  break;
130 
132  modifyGraphAlone(reinterpret_cast< const ArcReversal& >(change));
133  break;
134 
135  default:
136  GUM_ERROR(OperationNotAllowed,
137  "edge modifications are not supported by digraph constraint");
138  }
139  }
140 
143  const GraphChange&) const {
144  return false;
145  }
146 
148  INLINE void StructuralConstraintDiGraph::setGraph(Size nb_nodes) {
150 
151  for (NodeId i = 0; i < nb_nodes; ++i) {
153  }
154  }
155 
156 // include all the methods applicable to the whole class hierarchy
157 # define GUM_CONSTRAINT_CLASS_NAME StructuralConstraintDiGraph
159 # undef GUM_CONSTRAINT_CLASS_NAME
160 
161  } /* namespace learning */
162 
163 } /* namespace gum */
164 
165 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
virtual void addNodeWithId(const NodeId id)
try to insert a node with the given id
virtual void addArc(const NodeId tail, const NodeId head)
insert a new arc into the directed graph
Definition: diGraph_inl.h:35
void setGraph(Size nb_nodes)
sets a new empty graph from which we will perform checkings
void modifyGraphAlone(const ArcAddition &change)
notify the constraint of a modification of the graph
virtual void clear()
removes all the nodes and arcs from the graph
Definition: diGraph_inl.h:43
virtual void eraseArc(const Arc &arc)
removes an arc from the ArcGraphPart
void setGraphAlone(const DiGraph &graph)
sets a new graph from which we will perform checkings
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
DiGraph _DiGraph__graph
the DiGraph on which we perform checks
bool checkArcReversalAlone(NodeId x, NodeId y) const
checks whether the constraints enable to reverse arc (x,y)
bool checkArcAdditionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to add arc (x,y)
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId
bool isAlwaysInvalidAlone(const GraphChange &change) const
indicates whether a change will always violate the constraint
bool checkArcDeletionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to remove arc (x,y)
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
bool checkModificationAlone(const GraphChange &change) const
checks whether the constraints enable to perform a graph change
bool existsArc(const Arc &arc) const
indicates whether a given arc exists
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55