aGrUM  0.16.0
gum::learning::StructuralConstraintUndiGraph Class Reference

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

#include <structuralConstraintUndiGraph.h>

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

Public Member Functions

Constructors / Destructors
 StructuralConstraintUndiGraph ()
 default constructor More...
 
 StructuralConstraintUndiGraph (Size nb_nodes)
 constructor starting with an empty graph with a given number of nodes More...
 
 StructuralConstraintUndiGraph (const UndiGraph &graph)
 constructor starting with a given graph More...
 
 StructuralConstraintUndiGraph (const StructuralConstraintUndiGraph &from)
 copy constructor More...
 
 StructuralConstraintUndiGraph (StructuralConstraintUndiGraph &&from)
 move constructor More...
 
virtual ~StructuralConstraintUndiGraph ()
 destructor More...
 
Operators
StructuralConstraintUndiGraphoperator= (const StructuralConstraintUndiGraph &from)
 copy operator More...
 
StructuralConstraintUndiGraphoperator= (StructuralConstraintUndiGraph &&from)
 move operator More...
 
Specific Accessors / Modifiers
void setGraph (Size nb_nodes)
 sets a new empty graph from which we will perform checkings More...
 
void setGraphAlone (const UndiGraph &graph)
 sets a new graph from which we will perform checkings More...
 
void modifyGraphAlone (const EdgeAddition &change)
 notify the constraint of a modification of the graph More...
 
void modifyGraphAlone (const EdgeDeletion &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 checkEdgeAdditionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to add edge (x,y) More...
 
bool checkEdgeDeletionAlone (NodeId x, NodeId y) const
 checks whether the constraints enable to remove edge (x,y) More...
 
bool checkModificationAlone (const GraphChange &change) const
 checks whether the constraints enable to perform a graph change More...
 
bool checkModificationAlone (const EdgeAddition &change) const
 checks whether the constraints enable to add an edge More...
 
bool checkModificationAlone (const EdgeDeletion &change) const
 checks whether the constraints enable to remove an edge More...
 

Public Types

using allConstraints = __ConstraintSet< void >
 

Protected Attributes

UndiGraph _UndiGraph__graph
 the UndiGraph on which we perform checks More...
 

Detailed Description

The base class for structural constraints used by learning algorithms that learn an undirected graph structure.

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

Definition at line 50 of file structuralConstraintUndiGraph.h.

Member Typedef Documentation

◆ allConstraints

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

Definition at line 42 of file structuralConstraint.h.

Constructor & Destructor Documentation

◆ StructuralConstraintUndiGraph() [1/5]

gum::learning::StructuralConstraintUndiGraph::StructuralConstraintUndiGraph ( )

default constructor

Definition at line 42 of file structuralConstraintUndiGraph.cpp.

42  {
43  GUM_CONSTRUCTOR(StructuralConstraintUndiGraph);
44  }

◆ StructuralConstraintUndiGraph() [2/5]

gum::learning::StructuralConstraintUndiGraph::StructuralConstraintUndiGraph ( Size  nb_nodes)

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

Definition at line 47 of file structuralConstraintUndiGraph.cpp.

References setGraph().

47  {
48  setGraph(nb_nodes);
49  GUM_CONSTRUCTOR(StructuralConstraintUndiGraph);
50  }
void setGraph(Size nb_nodes)
sets a new empty graph from which we will perform checkings
+ Here is the call graph for this function:

◆ StructuralConstraintUndiGraph() [3/5]

gum::learning::StructuralConstraintUndiGraph::StructuralConstraintUndiGraph ( const UndiGraph graph)

constructor starting with a given graph

Definition at line 53 of file structuralConstraintUndiGraph.cpp.

References setGraph().

54  {
55  setGraph(graph);
56  GUM_CONSTRUCTOR(StructuralConstraintUndiGraph);
57  }
void setGraph(Size nb_nodes)
sets a new empty graph from which we will perform checkings
+ Here is the call graph for this function:

◆ StructuralConstraintUndiGraph() [4/5]

gum::learning::StructuralConstraintUndiGraph::StructuralConstraintUndiGraph ( const StructuralConstraintUndiGraph from)

copy constructor

Definition at line 60 of file structuralConstraintUndiGraph.cpp.

61  :
62  _UndiGraph__graph(from._UndiGraph__graph) {
63  GUM_CONS_CPY(StructuralConstraintUndiGraph);
64  }
UndiGraph _UndiGraph__graph
the UndiGraph on which we perform checks

◆ StructuralConstraintUndiGraph() [5/5]

gum::learning::StructuralConstraintUndiGraph::StructuralConstraintUndiGraph ( StructuralConstraintUndiGraph &&  from)

move constructor

Definition at line 67 of file structuralConstraintUndiGraph.cpp.

68  :
69  _UndiGraph__graph(std::move(from._UndiGraph__graph)) {
70  GUM_CONS_MOV(StructuralConstraintUndiGraph);
71  }
UndiGraph _UndiGraph__graph
the UndiGraph on which we perform checks

◆ ~StructuralConstraintUndiGraph()

gum::learning::StructuralConstraintUndiGraph::~StructuralConstraintUndiGraph ( )
virtual

destructor

Definition at line 74 of file structuralConstraintUndiGraph.cpp.

References operator=().

74  {
75  GUM_DESTRUCTOR(StructuralConstraintUndiGraph);
76  }
+ Here is the call graph for this function:

Member Function Documentation

◆ checkEdgeAdditionAlone()

bool gum::learning::StructuralConstraintUndiGraph::checkEdgeAdditionAlone ( NodeId  x,
NodeId  y 
) const

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

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

◆ checkEdgeDeletionAlone()

bool gum::learning::StructuralConstraintUndiGraph::checkEdgeDeletionAlone ( NodeId  x,
NodeId  y 
) const

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

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

◆ checkModificationAlone() [1/3]

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

checks whether the constraints enable to perform a graph change

An edge can be added if and only if its extremal nodes belong to the graph and the edge does not already exist. An edge can be removed if and only if the edge exists.

◆ checkModificationAlone() [2/3]

bool gum::learning::StructuralConstraintUndiGraph::checkModificationAlone ( const EdgeAddition change) const

checks whether the constraints enable to add an edge

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

◆ checkModificationAlone() [3/3]

bool gum::learning::StructuralConstraintUndiGraph::checkModificationAlone ( const EdgeDeletion change) const

checks whether the constraints enable to remove an edge

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

◆ isAlwaysInvalidAlone()

bool gum::learning::StructuralConstraintUndiGraph::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 edge (X,Y) addition is considered, the learning algorithm may discard this change because it violates the structural constraint, but, later on, other edge removals may induce that the edge 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/3]

void gum::learning::StructuralConstraintUndiGraph::modifyGraphAlone ( const EdgeAddition change)

notify the constraint of a modification of the graph

Warning
If an already existing edge is added nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if an edge (x,y) is added and x or y does not belong to the graph nodes

◆ modifyGraphAlone() [2/3]

void gum::learning::StructuralConstraintUndiGraph::modifyGraphAlone ( const EdgeDeletion change)

notify the constraint of a modification of the graph

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

◆ modifyGraphAlone() [3/3]

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

notify the constraint of a modification of the graph

Warning
If an already existing edge is added, or if a nonexisting edge is removed, nothing is done. In particular, no exception is raised.
Exceptions
InvalidNodeexception is thrown if an edge (x,y) is added and x or y does not belong to the graph nodes

◆ operator=() [1/2]

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

copy operator

Definition at line 80 of file structuralConstraintUndiGraph.cpp.

References _UndiGraph__graph.

Referenced by ~StructuralConstraintUndiGraph().

80  {
81  if (this != &from) { _UndiGraph__graph = from._UndiGraph__graph; }
82  return *this;
83  }
UndiGraph _UndiGraph__graph
the UndiGraph on which we perform checks
+ Here is the caller graph for this function:

◆ operator=() [2/2]

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

move operator

Definition at line 87 of file structuralConstraintUndiGraph.cpp.

References _UndiGraph__graph.

87  {
88  if (this != &from) { _UndiGraph__graph = std::move(from._UndiGraph__graph); }
89  return *this;
90  }
UndiGraph _UndiGraph__graph
the UndiGraph on which we perform checks

◆ setGraph()

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

sets a new empty graph from which we will perform checkings

Referenced by StructuralConstraintUndiGraph().

+ Here is the caller graph for this function:

◆ setGraphAlone()

void gum::learning::StructuralConstraintUndiGraph::setGraphAlone ( const UndiGraph graph)

sets a new graph from which we will perform checkings

Member Data Documentation

◆ _UndiGraph__graph

UndiGraph gum::learning::StructuralConstraintUndiGraph::_UndiGraph__graph
protected

the UndiGraph on which we perform checks

Definition at line 176 of file structuralConstraintUndiGraph.h.

Referenced by operator=().


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