aGrUM 2.3.2
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 Types

using constraints

Public Member Functions

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

Protected Attributes

DAGCycleDetector _DAG_cycle_detector_
 the cycle detector used to check quickly graph modifications

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 68 of file structuralConstraintDAG.h.

Member Typedef Documentation

◆ constraints

using gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph, OTHER_CONSTRAINTS >::constraints
inherited

Definition at line 425 of file structuralConstraintSetStatic.h.

Constructor & Destructor Documentation

◆ StructuralConstraintDAG() [1/5]

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

default constructor

Definition at line 59 of file structuralConstraintDAG.cpp.

59{ GUM_CONSTRUCTOR(StructuralConstraintDAG); }

References StructuralConstraintDAG().

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

Here is the call graph for this function:
Here is the caller 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 62 of file structuralConstraintDAG.cpp.

62 :
63 StructuralConstraintDiGraph(nb_nodes) {
65
66 DAG g;
67 for (NodeId i = 0; i < nb_nodes; ++i) {
68 g.addNodeWithId(i);
69 }
70 _DAG_cycle_detector_.setDAG(g);
71
72 GUM_CONSTRUCTOR(StructuralConstraintDAG);
73 }
DAGCycleDetector _DAG_cycle_detector_
the cycle detector used to check quickly graph modifications
void setGraph(Size nb_nodes)
sets a new empty graph from which we will perform checkings
Size NodeId
Type for node ids.

References StructuralConstraintDAG(), _DAG_cycle_detector_, gum::NodeGraphPart::addNodeWithId(), and gum::learning::StructuralConstraintDiGraph::setGraph().

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 76 of file structuralConstraintDAG.cpp.

76 {
78 _DAG_cycle_detector_.setDAG(graph);
79
80 GUM_CONSTRUCTOR(StructuralConstraintDAG);
81 }

References StructuralConstraintDAG(), _DAG_cycle_detector_, and gum::learning::StructuralConstraintDiGraph::setGraph().

Here is the call graph for this function:

◆ StructuralConstraintDAG() [4/5]

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

copy constructor

Definition at line 84 of file structuralConstraintDAG.cpp.

84 :
85 StructuralConstraintDiGraph(from), _DAG_cycle_detector_(from._DAG_cycle_detector_) {
86 GUM_CONS_CPY(StructuralConstraintDAG);
87 }

References StructuralConstraintDAG(), and _DAG_cycle_detector_.

Here is the call graph for this function:

◆ StructuralConstraintDAG() [5/5]

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

move constructor

Definition at line 90 of file structuralConstraintDAG.cpp.

90 :
91 StructuralConstraintDiGraph(std::move(from)),
92 _DAG_cycle_detector_(std::move(from._DAG_cycle_detector_)) {
93 GUM_CONS_MOV(StructuralConstraintDAG);
94 }

References StructuralConstraintDAG(), and _DAG_cycle_detector_.

Here is the call graph for this function:

◆ ~StructuralConstraintDAG()

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

destructor

Definition at line 97 of file structuralConstraintDAG.cpp.

97{ GUM_DESTRUCTOR(StructuralConstraintDAG); }

References 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()

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

checks whether the constraints enable to add an arc

◆ 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()

void gum::learning::StructuralConstraintSetStatic< StructuralConstraintDiGraph, OTHER_CONSTRAINTS >::modifyGraph ( const ArcAddition & 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 101 of file structuralConstraintDAG.cpp.

101 {
102 if (this != &from) {
104 _DAG_cycle_detector_ = from._DAG_cycle_detector_;
105 }
106 return *this;
107 }
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator

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

Here is the call graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 110 of file structuralConstraintDAG.cpp.

110 {
111 if (this != &from) {
113 _DAG_cycle_detector_ = std::move(from._DAG_cycle_detector_);
114 }
115 return *this;
116 }

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

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]

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 227 of file structuralConstraintDAG.h.

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


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