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

The base class for structural constraints used by learning algorithms that learn a directed graph structure. More...

#include <structuralConstraintDiGraph.h>

Inheritance diagram for gum::learning::StructuralConstraintDiGraph:
Collaboration diagram for gum::learning::StructuralConstraintDiGraph:

Public Types

using allConstraints = _ConstraintSet_< void >

Public Member Functions

Constructors / Destructors
 StructuralConstraintDiGraph ()
 default constructor
 StructuralConstraintDiGraph (Size nb_nodes)
 constructor starting with an empty graph with a given number of nodes
 StructuralConstraintDiGraph (const DiGraph &graph)
 constructor starting with a given graph
 StructuralConstraintDiGraph (const StructuralConstraintDiGraph &from)
 copy constructor
 StructuralConstraintDiGraph (StructuralConstraintDiGraph &&from)
 move constructor
virtual ~StructuralConstraintDiGraph ()
 destructor
Operators
StructuralConstraintDiGraphoperator= (const StructuralConstraintDiGraph &from)
 copy operator
StructuralConstraintDiGraphoperator= (StructuralConstraintDiGraph &&from)
 move operator
Specific Accessors / Modifiers
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 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 GraphChange &change) const
 checks whether the constraints enable to perform a graph change
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

Protected Attributes

DiGraph _DiGraph_graph_
 the DiGraph on which we perform checks

Detailed Description

The base class for structural constraints used by learning algorithms that learn a directed graph structure.

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 69 of file structuralConstraintDiGraph.h.

Member Typedef Documentation

◆ allConstraints

using gum::learning::StructuralConstraintEmpty::allConstraints = _ConstraintSet_< void >
inherited

Definition at line 61 of file structuralConstraint.h.

Constructor & Destructor Documentation

◆ StructuralConstraintDiGraph() [1/5]

gum::learning::StructuralConstraintDiGraph::StructuralConstraintDiGraph ( )

default constructor

Definition at line 61 of file structuralConstraintDiGraph.cpp.

61 {
62 GUM_CONSTRUCTOR(StructuralConstraintDiGraph);
63 }

References StructuralConstraintDiGraph().

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ StructuralConstraintDiGraph() [2/5]

gum::learning::StructuralConstraintDiGraph::StructuralConstraintDiGraph ( Size nb_nodes)

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

Definition at line 66 of file structuralConstraintDiGraph.cpp.

66 {
67 setGraph(nb_nodes);
68 GUM_CONSTRUCTOR(StructuralConstraintDiGraph);
69 }
void setGraph(Size nb_nodes)
sets a new empty graph from which we will perform checkings

References StructuralConstraintDiGraph(), and setGraph().

Here is the call graph for this function:

◆ StructuralConstraintDiGraph() [3/5]

gum::learning::StructuralConstraintDiGraph::StructuralConstraintDiGraph ( const DiGraph & graph)

constructor starting with a given graph

Definition at line 72 of file structuralConstraintDiGraph.cpp.

72 {
73 setGraph(graph);
74 GUM_CONSTRUCTOR(StructuralConstraintDiGraph);
75 }

References StructuralConstraintDiGraph(), and setGraph().

Here is the call graph for this function:

◆ StructuralConstraintDiGraph() [4/5]

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

copy constructor

Definition at line 78 of file structuralConstraintDiGraph.cpp.

79 : _DiGraph_graph_(from._DiGraph_graph_) {
80 GUM_CONS_CPY(StructuralConstraintDiGraph);
81 }
DiGraph _DiGraph_graph_
the DiGraph on which we perform checks

References StructuralConstraintDiGraph(), and _DiGraph_graph_.

Here is the call graph for this function:

◆ StructuralConstraintDiGraph() [5/5]

gum::learning::StructuralConstraintDiGraph::StructuralConstraintDiGraph ( StructuralConstraintDiGraph && from)

move constructor

Definition at line 84 of file structuralConstraintDiGraph.cpp.

84 :
85 _DiGraph_graph_(std::move(from._DiGraph_graph_)) {
86 GUM_CONS_MOV(StructuralConstraintDiGraph);
87 }

References StructuralConstraintDiGraph(), and _DiGraph_graph_.

Here is the call graph for this function:

◆ ~StructuralConstraintDiGraph()

gum::learning::StructuralConstraintDiGraph::~StructuralConstraintDiGraph ( )
virtual

destructor

Definition at line 90 of file structuralConstraintDiGraph.cpp.

90 {
91 GUM_DESTRUCTOR(StructuralConstraintDiGraph);
92 }

References StructuralConstraintDiGraph().

Here is the call graph for this function:

Member Function Documentation

◆ checkArcAdditionAlone()

bool gum::learning::StructuralConstraintDiGraph::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.

◆ checkArcDeletionAlone()

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

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

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

◆ checkArcReversalAlone()

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

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

an arc can be reversed if and only if it exists and arc (y,x) does not.

◆ checkModificationAlone() [1/4]

bool gum::learning::StructuralConstraintDiGraph::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::StructuralConstraintDiGraph::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::StructuralConstraintDiGraph::checkModificationAlone ( const ArcReversal & change) const

checks whether the constraints enable to reverse an arc

an arc (x,y) can be reversed if and only if it exists and arc (y,x) does not.

◆ checkModificationAlone() [4/4]

bool gum::learning::StructuralConstraintDiGraph::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. An arc can be removed if and only if the arc exists. An arc (x,y) can be reversed if and only if it exists and arc (y,x) does not.

◆ isAlwaysInvalidAlone()

bool gum::learning::StructuralConstraintDiGraph::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.

◆ modifyGraphAlone() [1/4]

void gum::learning::StructuralConstraintDiGraph::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

◆ modifyGraphAlone() [2/4]

void gum::learning::StructuralConstraintDiGraph::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::StructuralConstraintDiGraph::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

◆ modifyGraphAlone() [4/4]

void gum::learning::StructuralConstraintDiGraph::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

◆ operator=() [1/2]

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

copy operator

Definition at line 96 of file structuralConstraintDiGraph.cpp.

96 {
97 if (this != &from) { _DiGraph_graph_ = from._DiGraph_graph_; }
98 return *this;
99 }

References StructuralConstraintDiGraph(), and _DiGraph_graph_.

Referenced by gum::learning::StructuralConstraintDAG::operator=(), gum::learning::StructuralConstraintDAG::operator=(), gum::learning::StructuralConstraintIndegree::operator=(), gum::learning::StructuralConstraintIndegree::operator=(), gum::learning::StructuralConstraintSliceOrder::operator=(), and gum::learning::StructuralConstraintSliceOrder::operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 103 of file structuralConstraintDiGraph.cpp.

103 {
104 if (this != &from) { _DiGraph_graph_ = std::move(from._DiGraph_graph_); }
105 return *this;
106 }

References StructuralConstraintDiGraph(), and _DiGraph_graph_.

Here is the call graph for this function:

◆ setGraph()

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

sets a new empty graph from which we will perform checkings

Referenced by gum::learning::StructuralConstraintDAG::StructuralConstraintDAG(), gum::learning::StructuralConstraintDAG::StructuralConstraintDAG(), StructuralConstraintDiGraph(), and StructuralConstraintDiGraph().

Here is the caller graph for this function:

◆ setGraphAlone()

void gum::learning::StructuralConstraintDiGraph::setGraphAlone ( const DiGraph & graph)

sets a new graph from which we will perform checkings

Member Data Documentation

◆ _DiGraph_graph_

DiGraph gum::learning::StructuralConstraintDiGraph::_DiGraph_graph_
protected

the DiGraph on which we perform checks

Definition at line 211 of file structuralConstraintDiGraph.h.

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


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