aGrUM  0.16.0
gum::learning::StructuralConstraintIndegree Class Reference

the class for structural constraints limiting the number of parents of nodes in a directed graph More...

#include <structuralConstraintIndegree.h>

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

Public Member Functions

Constructors / Destructors
 StructuralConstraintIndegree ()
 default constructor More...
 
 StructuralConstraintIndegree (Size nb_nodes, Size max_indegree)
 constructor starting with an empty graph with a given number of nodes More...
 
 StructuralConstraintIndegree (const DiGraph &graph, Size max_indegree)
 constructor starting with a given graph More...
 
 StructuralConstraintIndegree (const StructuralConstraintIndegree &from)
 copy constructor More...
 
 StructuralConstraintIndegree (StructuralConstraintIndegree &&from)
 move constructor More...
 
virtual ~StructuralConstraintIndegree ()
 destructor More...
 
Operators
StructuralConstraintIndegreeoperator= (const StructuralConstraintIndegree &from)
 copy operator More...
 
StructuralConstraintIndegreeoperator= (StructuralConstraintIndegree &&from)
 move operator More...
 
Specific Accessors / Modifiers
void setIndegree (const NodeProperty< Size > &max_indegree)
 sets the default max indegree for all the nodes in the property More...
 
void setMaxIndegree (Size max_indegree, bool update_all_node=false)
 resets the default max indegree and possibly updates the indegree of all nodes More...
 
void setGraphAlone (const DiGraph &graph)
 sets a new 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...
 

Protected Attributes

NodeProperty< Size_Indegree__max_parents
 the max number of parents per node More...
 
Size _Indegree__max_indegree {std::numeric_limits< Size >::max()}
 a default max indegree to assign for nodes without specified indegree More...
 

Protected Member Functions

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...
 

Protected Types

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

Detailed Description

the class for structural constraints limiting the number of parents of nodes in a directed graph

Definition at line 49 of file structuralConstraintIndegree.h.

Member Typedef Documentation

◆ constraints

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

Definition at line 433 of file structuralConstraintSetStatic.h.

Constructor & Destructor Documentation

◆ StructuralConstraintIndegree() [1/5]

gum::learning::StructuralConstraintIndegree::StructuralConstraintIndegree ( )

default constructor

Definition at line 42 of file structuralConstraintIndegree.cpp.

42  {
43  GUM_CONSTRUCTOR(StructuralConstraintIndegree);
44  }

◆ StructuralConstraintIndegree() [2/5]

gum::learning::StructuralConstraintIndegree::StructuralConstraintIndegree ( Size  nb_nodes,
Size  max_indegree 
)

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

Definition at line 47 of file structuralConstraintIndegree.cpp.

References _Indegree__max_parents.

48  :
49  StructuralConstraintDiGraph(nb_nodes),
50  _Indegree__max_indegree(max_indegree) {
51  for (NodeId i = 0; i < nb_nodes; ++i) {
52  _Indegree__max_parents.insert(i, max_indegree);
53  }
54  GUM_CONSTRUCTOR(StructuralConstraintIndegree);
55  }
Size _Indegree__max_indegree
a default max indegree to assign for nodes without specified indegree
NodeProperty< Size > _Indegree__max_parents
the max number of parents per node
Size NodeId
Type for node ids.
Definition: graphElements.h:98

◆ StructuralConstraintIndegree() [3/5]

gum::learning::StructuralConstraintIndegree::StructuralConstraintIndegree ( const DiGraph graph,
Size  max_indegree 
)

constructor starting with a given graph

Definition at line 58 of file structuralConstraintIndegree.cpp.

References _Indegree__max_parents.

59  :
60  StructuralConstraintDiGraph(graph),
61  _Indegree__max_indegree(max_indegree) {
62  for (const auto id : graph) {
63  _Indegree__max_parents.insert(id, max_indegree);
64  }
65  GUM_CONSTRUCTOR(StructuralConstraintIndegree);
66  }
Size _Indegree__max_indegree
a default max indegree to assign for nodes without specified indegree
NodeProperty< Size > _Indegree__max_parents
the max number of parents per node

◆ StructuralConstraintIndegree() [4/5]

gum::learning::StructuralConstraintIndegree::StructuralConstraintIndegree ( const StructuralConstraintIndegree from)

copy constructor

Definition at line 69 of file structuralConstraintIndegree.cpp.

70  :
71  StructuralConstraintDiGraph(from),
72  _Indegree__max_parents(from._Indegree__max_parents),
73  _Indegree__max_indegree(from._Indegree__max_indegree) {
74  GUM_CONS_CPY(StructuralConstraintIndegree);
75  }
Size _Indegree__max_indegree
a default max indegree to assign for nodes without specified indegree
NodeProperty< Size > _Indegree__max_parents
the max number of parents per node

◆ StructuralConstraintIndegree() [5/5]

gum::learning::StructuralConstraintIndegree::StructuralConstraintIndegree ( StructuralConstraintIndegree &&  from)

move constructor

Definition at line 78 of file structuralConstraintIndegree.cpp.

79  :
80  StructuralConstraintDiGraph(std::move(from)),
81  _Indegree__max_parents(std::move(from._Indegree__max_parents)),
82  _Indegree__max_indegree(std::move(from._Indegree__max_indegree)) {
83  GUM_CONS_MOV(StructuralConstraintIndegree);
84  }
Size _Indegree__max_indegree
a default max indegree to assign for nodes without specified indegree
NodeProperty< Size > _Indegree__max_parents
the max number of parents per node

◆ ~StructuralConstraintIndegree()

gum::learning::StructuralConstraintIndegree::~StructuralConstraintIndegree ( )
virtual

destructor

Definition at line 87 of file structuralConstraintIndegree.cpp.

References operator=().

87  {
88  GUM_DESTRUCTOR(StructuralConstraintIndegree);
89  }
+ 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::StructuralConstraintIndegree::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 its addition would not violate the indegree constraint of y.

◆ 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::StructuralConstraintIndegree::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.

◆ 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::StructuralConstraintIndegree::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 and its addition would not violate the indegree constraint of x.

◆ 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::StructuralConstraintIndegree::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 and its addition would not violate the indegree constraint of y.

◆ checkModificationAlone() [2/4]

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

checks whether the constraints enable to reverse an arc

an arc can be reversed if and only if it exists and arc (y,x) does not and its addition would not violate the indegree constraint of x.

◆ checkModificationAlone() [4/4]

bool gum::learning::StructuralConstraintIndegree::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 its addition would not violate the indegree constraint of y. An arc can be removed if and only if the arc exists. An arc can be reversed if and only if it exists and arc (y,x) does not and its addition would not violate the indegree constraint of x.

◆ 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::StructuralConstraintIndegree::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::StructuralConstraintIndegree::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
OutOfUpperBoundexception is thrown if the indegree constraint is violated by the arc addition.

◆ modifyGraphAlone() [2/4]

void gum::learning::StructuralConstraintIndegree::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::StructuralConstraintIndegree::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 an arc (x,y) is added and x or y does not belong to the graph nodes
OutOfUpperBoundexception is thrown if the indegree constraint is violated by the arc reversal.

◆ modifyGraphAlone() [4/4]

void gum::learning::StructuralConstraintIndegree::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
OutOfUpperBoundexception is thrown if the indegree constraint is violated by an arc addition or reversal.

◆ operator=() [1/2]

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

copy operator

Definition at line 93 of file structuralConstraintIndegree.cpp.

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

Referenced by ~StructuralConstraintIndegree().

93  {
94  if (this != &from) {
96  _Indegree__max_parents = from._Indegree__max_parents;
97  _Indegree__max_indegree = from._Indegree__max_indegree;
98  }
99 
100  return *this;
101  }
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator
Size _Indegree__max_indegree
a default max indegree to assign for nodes without specified indegree
NodeProperty< Size > _Indegree__max_parents
the max number of parents per node
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 105 of file structuralConstraintIndegree.cpp.

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

105  {
106  if (this != &from) {
108  _Indegree__max_parents = std::move(from._Indegree__max_parents);
109  _Indegree__max_indegree = std::move(from._Indegree__max_indegree);
110  }
111 
112  return *this;
113  }
StructuralConstraintDiGraph & operator=(const StructuralConstraintDiGraph &from)
copy operator
Size _Indegree__max_indegree
a default max indegree to assign for nodes without specified indegree
NodeProperty< Size > _Indegree__max_parents
the max number of parents per node
+ Here is the call graph for this function:

◆ setGraph()

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

sets a new graph from which we will perform checkings

◆ setGraphAlone()

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

sets a new graph from which we will perform checkings

◆ setIndegree()

void gum::learning::StructuralConstraintIndegree::setIndegree ( const NodeProperty< Size > &  max_indegree)

sets the default max indegree for all the nodes in the property

◆ setMaxIndegree()

void gum::learning::StructuralConstraintIndegree::setMaxIndegree ( Size  max_indegree,
bool  update_all_node = false 
)

resets the default max indegree and possibly updates the indegree of all nodes

Referenced by gum::learning::genericBNLearner::setMaxIndegree().

+ Here is the caller graph for this function:

Member Data Documentation

◆ _Indegree__max_indegree

Size gum::learning::StructuralConstraintIndegree::_Indegree__max_indegree {std::numeric_limits< Size >::max()}
protected

a default max indegree to assign for nodes without specified indegree

Definition at line 213 of file structuralConstraintIndegree.h.

Referenced by operator=().

◆ _Indegree__max_parents

NodeProperty< Size > gum::learning::StructuralConstraintIndegree::_Indegree__max_parents
protected

the max number of parents per node

Definition at line 210 of file structuralConstraintIndegree.h.

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


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