25 #ifndef DOXYGEN_SHOULD_SKIP_THIS 40 for (
auto node : graph)
41 g.addNodeWithId(node);
43 for (
auto& arc : graph.arcs())
44 g.addArc(arc.tail(), arc.head());
53 for (
NodeId i = 0; i < nb_nodes; ++i) {
80 const ArcAddition& change)
const {
86 const ArcDeletion& change)
const {
92 const ArcReversal& change)
const {
98 const GraphChange& change)
const {
99 switch (change.type()) {
111 "edge modifications are not " 112 "supported by StructuralConstraintDAG");
137 switch (change.type()) {
152 "edge modifications are not supported by DAG constraints");
164 constraints::setGraph(graph);
175 # define GUM_CONSTRAINT_CLASS_NAME StructuralConstraintDAG 177 # undef GUM_CONSTRAINT_CLASS_NAME bool checkModificationAlone(const ArcAddition &change) const
checks whether the constraints enable to add an arc
void setGraph(const DAG &graph)
sets a new graph from which we will perform checkings
void setGraph(Size nb_nodes)
sets a new empty graph from which we will perform checkings
void setGraphAlone(const DiGraph &graph)
sets a new graph from which we will perform checkings
void eraseArc(NodeId x, NodeId y)
removes an arc from the current DAG
void addArc(NodeId x, NodeId y)
adds a new arc to the current DAG
void modifyGraphAlone(const ArcAddition &change)
notify the constraint of a modification of the graph
gum is the global namespace for all aGrUM entities
bool checkArcAdditionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to add arc (x,y)
bool isAlwaysInvalidAlone(const GraphChange &change) const
indicates whether a change will always violate the constraint
void setDAG(const DAG &dag)
sets the initial DAG from which changes shall be applied
the base class for structural constraints used by learning algorithms that learn a directed graph str...
bool checkArcReversalAlone(NodeId x, NodeId y) const
checks whether the constraints enable to reverse arc (x,y)
A class for detecting directed cycles in DAGs when trying to apply many changes to the graph...
bool checkArcDeletionAlone(NodeId x, NodeId y) const
checks whether the constraints enable to remove arc (x,y)
bool hasCycleFromAddition(NodeId x, NodeId y) const noexcept
indicates whether an arc addition would create a cycle
bool hasCycleFromReversal(NodeId x, NodeId y) const noexcept
indicates wether an arc reversal would create a cycle
bool hasCycleFromDeletion(NodeId x, NodeId y) const noexcept
indicates whether an arc deletion would create a cycle
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size NodeId
Type for node ids.
DAGCycleDetector _DAG__cycle_detector
the cycle detector used to check quickly graph modifications
#define GUM_ERROR(type, msg)
void reverseArc(NodeId x, NodeId y)
reverses an arc from the DAG