aGrUM  0.13.2
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 46 of file structuralConstraintDAG.h.

Member Typedef Documentation

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

Definition at line 429 of file structuralConstraintSetStatic.h.

Constructor & Destructor Documentation

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

default constructor

Definition at line 37 of file structuralConstraintDAG.cpp.

37  {
38  GUM_CONSTRUCTOR(StructuralConstraintDAG);
39  }
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 _DAG__cycle_detector, gum::NodeGraphPart::addNodeWithId(), gum::DAGCycleDetector::setDAG(), and gum::learning::StructuralConstraintDiGraph::setGraph().

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  }
unsigned int NodeId
Type for node ids.
Definition: graphElements.h:97
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:

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

constructor starting with a given graph

Definition at line 56 of file structuralConstraintDAG.cpp.

References _DAG__cycle_detector, gum::DAGCycleDetector::setDAG(), and gum::learning::StructuralConstraintDiGraph::setGraph().

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:

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

copy constructor

Definition at line 64 of file structuralConstraintDAG.cpp.

65  :
66  StructuralConstraintDiGraph(from),
67  _DAG__cycle_detector(from._DAG__cycle_detector) {
68  GUM_CONS_CPY(StructuralConstraintDAG);
69  }
DAGCycleDetector _DAG__cycle_detector
the cycle detector used to check quickly graph modifications
gum::learning::StructuralConstraintDAG::StructuralConstraintDAG ( StructuralConstraintDAG &&  from)

move constructor

Definition at line 72 of file structuralConstraintDAG.cpp.

73  :
74  StructuralConstraintDiGraph(std::move(from)),
75  _DAG__cycle_detector(std::move(from._DAG__cycle_detector)) {
76  GUM_CONS_MOV(StructuralConstraintDAG);
77  }
DAGCycleDetector _DAG__cycle_detector
the cycle detector used to check quickly graph modifications
gum::learning::StructuralConstraintDAG::~StructuralConstraintDAG ( )
virtual

destructor

Definition at line 80 of file structuralConstraintDAG.cpp.

References operator=().

80  {
81  GUM_DESTRUCTOR(StructuralConstraintDAG);
82  }

+ Here is the call graph for this function:

Member Function Documentation

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

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

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

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

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

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

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

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

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

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.

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

checks whether the constraints enable to add an arc

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

checks whether the constraints enable to remove an arc

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

checks whether the constraints enable to reverse an arc

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

checks whether the constraints enable to perform a graph change

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.

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.

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.

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.

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

indicates whether a change will always violate the constraint

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.

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

notify the constraint of a modification of the graph

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

notify the constraint of a modification of the graph

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

notify the constraint of a modification of the graph

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

notify the constraint of a modification of the graph

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.
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.
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.
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.
StructuralConstraintDAG & gum::learning::StructuralConstraintDAG::operator= ( const StructuralConstraintDAG from)

copy operator

Definition at line 86 of file structuralConstraintDAG.cpp.

References _DAG__cycle_detector, and gum::learning::StructuralConstraintDiGraph::operator=().

Referenced by ~StructuralConstraintDAG().

86  {
87  if (this != &from) {
89  _DAG__cycle_detector = from._DAG__cycle_detector;
90  }
91  return *this;
92  }
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:

+ Here is the caller graph for this function:

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

move operator

Definition at line 96 of file structuralConstraintDAG.cpp.

References _DAG__cycle_detector, and gum::learning::StructuralConstraintDiGraph::operator=().

96  {
97  if (this != &from) {
99  _DAG__cycle_detector = std::move(from._DAG__cycle_detector);
100  }
101  return *this;
102  }
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:

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

sets a new graph from which we will perform checkings

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

sets a new empty graph from which we will perform checkings

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

sets a new graph from which we will perform checkings

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

sets a new graph from which we will perform checkings

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

sets a new empty graph from which we will perform checkings

Member Data Documentation

DAGCycleDetector gum::learning::StructuralConstraintDAG::_DAG__cycle_detector
protected

the cycle detector used to check quickly graph modifications

Definition at line 206 of file structuralConstraintDAG.h.

Referenced by operator=(), and StructuralConstraintDAG().


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