aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::learning::StructuralConstraintDAG Class Reference

The base class for structural constraints imposed by DAGs. More...

#include <structuralConstraintDAG.h>

+ Inheritance diagram for gum::learning::StructuralConstraintDAG:
+ Collaboration diagram for gum::learning::StructuralConstraintDAG:

Public Member Functions

Constructors / Destructors
 StructuralConstraintDAG ()
 default constructor More...
 
 StructuralConstraintDAG (Size nb_nodes)
 constructor starting with an empty graph with a given number of nodes More...
 
 StructuralConstraintDAG (const DAG &graph)
 constructor starting with a given graph More...
 
 StructuralConstraintDAG (const StructuralConstraintDAG &from)
 copy constructor More...
 
 StructuralConstraintDAG (StructuralConstraintDAG &&from)
 move constructor More...
 
virtual ~StructuralConstraintDAG ()
 destructor More...
 
Operators
StructuralConstraintDAGoperator= (const StructuralConstraintDAG &from)
 copy operator More...
 
StructuralConstraintDAGoperator= (StructuralConstraintDAG &&from)
 move operator More...
 
Specific Accessors / Modifiers
void setGraphAlone (const DiGraph &graph)
 sets a new graph from which we will perform checkings More...
 
void setGraphAlone (Size nb_nodes)
 sets a new empty graph from which we will perform checkings More...
 
void modifyGraphAlone (const ArcAddition &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const ArcDeletion &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const ArcReversal &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const GraphChange &change)
 notify the constraint of a modification of the graph More...
 
bool isAlwaysInvalidAlone (const GraphChange &change) const
 indicates whether a change will always violate the constraint More...
 
bool checkArcAdditionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to add arc (x,y) More...
 
bool checkArcDeletionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to remove arc (x,y) More...
 
bool checkArcReversalAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to reverse arc (x,y) More...
 
bool checkModificationAlone (const ArcAddition &change) const
 checks whether the constraints enable to add an arc More...
 
bool checkModificationAlone (const ArcDeletion &change) const
 checks whether the constraints enable to remove an arc More...
 
bool checkModificationAlone (const ArcReversal &change) const
 checks whether the constraints enable to reverse an arc More...
 
bool checkModificationAlone (const GraphChange &change) const
 checks whether the constraints enable to perform a graph change More...
 
void setGraph (const DAG &graph)
 sets a new graph from which we will perform checkings More...
 
void setGraph (Size nb_nodes)
 sets a new empty graph from which we will perform checkings More...
 
Accessors / Modifiers
void setGraph (const DiGraph &graph)
 sets a new graph from which we will perform checkings More...
 
void modifyGraph (const ArcAddition &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraph (const ArcDeletion &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraph (const ArcReversal &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraph (const GraphChange &change)
 notify the constraint of a modification of the graph More...
 
bool isAlwaysInvalid (const GraphChange &change) const
 indicates whether a change will always violate the constraint More...
 
bool checkArcAddition (NodeId x, NodeId y) const
 checks whether the constraints enable to add arc (x,y) More...
 
bool checkArcDeletion (NodeId x, NodeId y) const
 checks whether the constraints enable to remove arc (x,y) More...
 
bool checkArcReversal (NodeId x, NodeId y) const
 checks whether the constraints enable to reverse arc (x,y) More...
 
bool checkModification (const ArcAddition &change) const
 checks whether the constraints enable to add an arc More...
 
bool checkModification (const ArcDeletion &change) const
 checks whether the constraints enable to remove an arc More...
 
bool checkModification (const ArcReversal &change) const
 checks whether the constraints enable to reverse an arc More...
 
bool checkModification (const GraphChange &change) const
 checks whether the constraints enable to perform a graph change More...
 

Public Types

using constraints = typename _StructuralConstraintSetStatic_< StructuralConstraintDiGraph, OTHER_CONSTRAINTS... >::minConstraints
 

Protected Attributes

DAGCycleDetector _DAG_cycle_detector_
 the cycle detector used to check quickly graph modifications More...
 

Detailed Description

The base class for structural constraints imposed by DAGs.

This base should always be a virtual parents of the structural constraints classes. This will allow to combine different constraints into a single class

Definition at line 48 of file structuralConstraintDAG.h.

Member Typedef Documentation

◆ constraints

using gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::constraints = typename _StructuralConstraintSetStatic_< StructuralConstraintDiGraph , OTHER_CONSTRAINTS... >::minConstraints
inherited

Definition at line 408 of file structuralConstraintSetStatic.h.

Constructor & Destructor Documentation

◆ StructuralConstraintDAG() [1/5]

gum::learning::StructuralConstraintDAG::StructuralConstraintDAG ( )

default constructor

Definition at line 39 of file structuralConstraintDAG.cpp.

References gum::learning::genericBNLearner::Database::Database().

39 { GUM_CONSTRUCTOR(StructuralConstraintDAG); }
+ Here is the call graph for this function:

◆ StructuralConstraintDAG() [2/5]

gum::learning::StructuralConstraintDAG::StructuralConstraintDAG ( Size  nb_nodes)

constructor starting with an empty graph with a given number of nodes

Definition at line 42 of file structuralConstraintDAG.cpp.

References gum::learning::genericBNLearner::Database::Database().

42  :
43  StructuralConstraintDiGraph(nb_nodes) {
45 
46  DAG g;
47  for (NodeId i = 0; i < nb_nodes; ++i) {
48  g.addNodeWithId(i);
49  }
51 
52  GUM_CONSTRUCTOR(StructuralConstraintDAG);
53  }
void setGraph(Size nb_nodes)
sets a new empty graph from which we will perform checkings
void setDAG(const DAG &dag)
sets the initial DAG from which changes shall be applied
DAGCycleDetector _DAG_cycle_detector_
the cycle detector used to check quickly graph modifications
Size NodeId
Type for node ids.
Definition: graphElements.h:97
+ Here is the call graph for this function:

◆ StructuralConstraintDAG() [3/5]

gum::learning::StructuralConstraintDAG::StructuralConstraintDAG ( const DAG graph)

constructor starting with a given graph

Definition at line 56 of file structuralConstraintDAG.cpp.

References gum::learning::genericBNLearner::Database::Database().

56  {
59 
60  GUM_CONSTRUCTOR(StructuralConstraintDAG);
61  }
void setGraph(Size nb_nodes)
sets a new empty graph from which we will perform checkings
void setDAG(const DAG &dag)
sets the initial DAG from which changes shall be applied
DAGCycleDetector _DAG_cycle_detector_
the cycle detector used to check quickly graph modifications
+ Here is the call graph for this function:

◆ StructuralConstraintDAG() [4/5]

gum::learning::StructuralConstraintDAG::StructuralConstraintDAG ( const StructuralConstraintDAG from)

copy constructor

Definition at line 64 of file structuralConstraintDAG.cpp.

References gum::learning::genericBNLearner::Database::Database().

64  :
65  StructuralConstraintDiGraph(from), _DAG_cycle_detector_(from._DAG_cycle_detector_) {
66  GUM_CONS_CPY(StructuralConstraintDAG);
67  }
DAGCycleDetector _DAG_cycle_detector_
the cycle detector used to check quickly graph modifications
+ Here is the call graph for this function:

◆ StructuralConstraintDAG() [5/5]

gum::learning::StructuralConstraintDAG::StructuralConstraintDAG ( StructuralConstraintDAG &&  from)

move constructor

Definition at line 70 of file structuralConstraintDAG.cpp.

References gum::learning::genericBNLearner::Database::Database().

70  :
71  StructuralConstraintDiGraph(std::move(from)),
72  _DAG_cycle_detector_(std::move(from._DAG_cycle_detector_)) {
73  GUM_CONS_MOV(StructuralConstraintDAG);
74  }
DAGCycleDetector _DAG_cycle_detector_
the cycle detector used to check quickly graph modifications
+ Here is the call graph for this function:

◆ ~StructuralConstraintDAG()

gum::learning::StructuralConstraintDAG::~StructuralConstraintDAG ( )
virtual

destructor

Definition at line 77 of file structuralConstraintDAG.cpp.

References gum::learning::genericBNLearner::Database::Database().

77 { GUM_DESTRUCTOR(StructuralConstraintDAG); }
+ Here is the call graph for this function:

Member Function Documentation

◆ checkArcAddition()

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkArcAddition ( NodeId  x,
NodeId  y 
) const
inherited

checks whether the constraints enable to add arc (x,y)

◆ checkArcAdditionAlone()

bool gum::learning::StructuralConstraintDAG::checkArcAdditionAlone ( NodeId  x,
NodeId  y 
) const

checks whether the constraints enable to add arc (x,y)

an arc can be added if and only if its extremal nodes belong to the graph and the arc does not already exist and would not create a cycle

◆ checkArcDeletion()

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkArcDeletion ( NodeId  x,
NodeId  y 
) const
inherited

checks whether the constraints enable to remove arc (x,y)

◆ checkArcDeletionAlone()

bool gum::learning::StructuralConstraintDAG::checkArcDeletionAlone ( NodeId  x,
NodeId  y 
) const

checks whether the constraints enable to remove arc (x,y)

◆ checkArcReversal()

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkArcReversal ( NodeId  x,
NodeId  y 
) const
inherited

checks whether the constraints enable to reverse arc (x,y)

◆ checkArcReversalAlone()

bool gum::learning::StructuralConstraintDAG::checkArcReversalAlone ( NodeId  x,
NodeId  y 
) const

checks whether the constraints enable to reverse arc (x,y)

An arc (x,y) can be reversed if and only if it exists and, after deleting it, the addition of arc (y,x) does not induce a directed cycle.

◆ checkModification() [1/4]

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkModification ( const ArcAddition change) const
inherited

checks whether the constraints enable to add an arc

◆ checkModification() [2/4]

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkModification ( const ArcDeletion change) const
inherited

checks whether the constraints enable to remove an arc

◆ checkModification() [3/4]

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkModification ( const ArcReversal change) const
inherited

checks whether the constraints enable to reverse an arc

◆ checkModification() [4/4]

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::checkModification ( const GraphChange change) const
inherited

checks whether the constraints enable to perform a graph change

◆ checkModificationAlone() [1/4]

bool gum::learning::StructuralConstraintDAG::checkModificationAlone ( const ArcAddition change) const

checks whether the constraints enable to add an arc

an arc can be added if and only if its extremal nodes belong to the graph and the arc does not already exist.

◆ checkModificationAlone() [2/4]

bool gum::learning::StructuralConstraintDAG::checkModificationAlone ( const ArcDeletion change) const

checks whether the constraints enable to remove an arc

an arc can be removed if and only if the arc exists.

◆ checkModificationAlone() [3/4]

bool gum::learning::StructuralConstraintDAG::checkModificationAlone ( const ArcReversal change) const

checks whether the constraints enable to reverse an arc

An arc can be reversed if, after deleting arc (x,y), the addition of arc (y,x) does not induce a directed cycle.

◆ checkModificationAlone() [4/4]

bool gum::learning::StructuralConstraintDAG::checkModificationAlone ( const GraphChange change) const

checks whether the constraints enable to perform a graph change

an arc can be added if and only if its extremal nodes belong to the graph and the arc does not already exist and would not create a cycle. An arc can be removed if and only if the arc exists. An arc can be reversed if, after deleting arc (x,y), the addition of arc (y,x) does not induce a directed cycle.

◆ isAlwaysInvalid()

bool gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::isAlwaysInvalid ( const GraphChange change) const
inherited

indicates whether a change will always violate the constraint

◆ isAlwaysInvalidAlone()

bool gum::learning::StructuralConstraintDAG::isAlwaysInvalidAlone ( const GraphChange change) const

indicates whether a change will always violate the constraint

Some learning algorithms need examine several times whether a given graph change can be applied. For instance, the first time arc (X,Y) addition is considered, the learning algorithm may discard this change because it violates the structural constraint (e.g., if the latter enforces a DAG structure, this arc addition might induce a directed cycle), but, later on, other arc removal may induce that the arc addition is now possible. Such change is thus not always invalid. Conversely, there are changes that can be discarded once and for all. For instance, in a 2TBN structure, it is always impossible to add a backward-time arc. Such graph changes are always invalid and are therefore tagged as such by the isAlwaysInvalid method.

◆ modifyGraph() [1/4]

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::modifyGraph ( const ArcAddition change)
inherited

notify the constraint of a modification of the graph

◆ modifyGraph() [2/4]

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::modifyGraph ( const ArcDeletion change)
inherited

notify the constraint of a modification of the graph

◆ modifyGraph() [3/4]

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::modifyGraph ( const ArcReversal change)
inherited

notify the constraint of a modification of the graph

◆ modifyGraph() [4/4]

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::modifyGraph ( const GraphChange change)
inherited

notify the constraint of a modification of the graph

◆ modifyGraphAlone() [1/4]

void gum::learning::StructuralConstraintDAG::modifyGraphAlone ( const ArcAddition change)

notify the constraint of a modification of the graph

Warning
If an already existing arc is added nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if an arc (x,y) is added and x or y does not belong to the graph nodes
InvalidDirectedCycleexception is thrown if any (directed) cycle is created by the arc addition.

◆ modifyGraphAlone() [2/4]

void gum::learning::StructuralConstraintDAG::modifyGraphAlone ( const ArcDeletion change)

notify the constraint of a modification of the graph

Warning
If a nonexisting arc is removed, nothing is done. In particular, no exception is raised.

◆ modifyGraphAlone() [3/4]

void gum::learning::StructuralConstraintDAG::modifyGraphAlone ( const ArcReversal change)

notify the constraint of a modification of the graph

Warning
If an already existing arc is added, or if a nonexisting arc is removed, nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if at least one extremity of the arc does not belong to the graph nodes
InvalidDirectedCycleexception is thrown if any (directed) cycle is created by the arc reversal.

◆ modifyGraphAlone() [4/4]

void gum::learning::StructuralConstraintDAG::modifyGraphAlone ( const GraphChange change)

notify the constraint of a modification of the graph

Warning
If an already existing arc is added, or if a nonexisting arc is removed, nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if an arc (x,y) is added and x or y does not belong to the graph nodes
InvalidDirectedCycleexception is thrown if any (directed) cycle is created by an arc addition or reversal.

◆ operator=() [1/2]

StructuralConstraintDAG & gum::learning::StructuralConstraintDAG::operator= ( const StructuralConstraintDAG from)

copy operator

Definition at line 81 of file structuralConstraintDAG.cpp.

References gum::learning::genericBNLearner::Database::Database().

81  {
82  if (this != &from) {
84  _DAG_cycle_detector_ = from._DAG_cycle_detector_;
85  }
86  return *this;
87  }
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator
DAGCycleDetector _DAG_cycle_detector_
the cycle detector used to check quickly graph modifications
+ Here is the call graph for this function:

◆ operator=() [2/2]

StructuralConstraintDAG & gum::learning::StructuralConstraintDAG::operator= ( StructuralConstraintDAG &&  from)

move operator

Definition at line 90 of file structuralConstraintDAG.cpp.

References gum::learning::genericBNLearner::Database::Database().

90  {
91  if (this != &from) {
93  _DAG_cycle_detector_ = std::move(from._DAG_cycle_detector_);
94  }
95  return *this;
96  }
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator
DAGCycleDetector _DAG_cycle_detector_
the cycle detector used to check quickly graph modifications
+ Here is the call graph for this function:

◆ setGraph() [1/3]

void gum::learning::StructuralConstraintDAG::setGraph ( const DAG graph)

sets a new graph from which we will perform checkings

◆ setGraph() [2/3]

void gum::learning::StructuralConstraintDAG::setGraph ( Size  nb_nodes)

sets a new empty graph from which we will perform checkings

◆ setGraph() [3/3]

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph , OTHER_CONSTRAINTS >::setGraph ( const DiGraph graph)
inherited

sets a new graph from which we will perform checkings

◆ setGraphAlone() [1/2]

void gum::learning::StructuralConstraintDAG::setGraphAlone ( const DiGraph graph)

sets a new graph from which we will perform checkings

◆ setGraphAlone() [2/2]

void gum::learning::StructuralConstraintDAG::setGraphAlone ( Size  nb_nodes)

sets a new empty graph from which we will perform checkings

Member Data Documentation

◆ _DAG_cycle_detector_

DAGCycleDetector gum::learning::StructuralConstraintDAG::_DAG_cycle_detector_
protected

the cycle detector used to check quickly graph modifications

Definition at line 207 of file structuralConstraintDAG.h.


The documentation for this class was generated from the following files: