![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Class implementingting a function graph manager. More...
#include <multiDimFunctionGraph.h>
Public Member Functions | |
void | clean () |
Removes var without nodes in the diagram. More... | |
Constructors / Destructors | |
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * | MultiDimFunctionGraph () |
This friend methods from is the only way to get an instance of a manager. More... | |
MultiDimFunctionGraphManager (MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy > *master) | |
Default constructor. More... | |
virtual | ~MultiDimFunctionGraphManager () |
Class destructor. More... | |
Nodes manipulation methods. | |
NodeId | addInternalNode_ (const DiscreteVariable *var, NodeId *sons) |
Adds an internal node. More... | |
void | setRootNode (const NodeId &root) |
Sets root node of decision diagram. More... | |
NodeId | addInternalNode (const DiscreteVariable *var) |
Inserts a new non terminal node in graph. More... | |
virtual NodeId | addInternalNode (const DiscreteVariable *var, NodeId *sons)=0 |
Inserts a new non terminal node in graph. More... | |
NodeId | addInternalNode (const DiscreteVariable *var, NodeId nid) |
Inserts a new non terminal node in graph. More... | |
NodeId | addTerminalNode (const GUM_SCALAR &value) |
Adds a value to the MultiDimFunctionGraph. More... | |
void | eraseNode (NodeId id, NodeId replacingId=0, bool updateParents=true) |
Erases a node from the diagram. More... | |
Manipulation methods. | |
void | migrateNode_ (const NodeId &x, const NodeId &y) |
Remaps all arcs going to ou going from the first given node to the second node, then delete first node. More... | |
void | setSon (const NodeId &node, const Idx &modality, const NodeId &sonNode) |
Sets nodes son for given modality to designated son node. More... | |
void | minimizeSize () |
Performs a sifting in search of a(local) minimal size. More... | |
void | moveTo (const DiscreteVariable *x, Idx desiredPos) |
Changes var position in variable sequence. More... | |
void | _adjacentSwap_ (const DiscreteVariable *x, const DiscreteVariable *y) |
Swap two adjacent variable. More... | |
Redundancy methods. | |
NodeId | nodeRedundancyCheck_ (const DiscreteVariable *var, NodeId *sonsMap) |
Check for redundancy. More... | |
void | reduce_ () |
Ensures that every isomorphic subgraphs are merged together. More... | |
virtual void | reduce ()=0 |
Ensures that every isomorphic subgraphs are merged together. More... | |
NodeId | _checkIsomorphism_ (const DiscreteVariable *var, NodeId *sons) |
Checks if a similar node does not already exists in the graph. More... | |
bool | _isRedundant_ (const DiscreteVariable *var, NodeId *sons) |
Checks if node has the same child for every variable value. More... | |
Class implementingting a function graph manager.
This class provides methods to edit a Function Graph. Any modification on a MultiDimFunctionGraph graph must be done via this class.
This class is a singleton and its unique instance ca be accessed using the MultiDimFunctionGraph::getManager() method.
To do so :
GUM_SCALAR | The type of scalars stored in the multidimensional table. |
TerminalNodePolicy | The terminal node policy to use. |
Definition at line 52 of file multiDimFunctionGraph.h.
|
explicitprotected |
Default constructor.
You have to call MultiDimFunctionGraph::getManager() to get the instance of MultiDimFunctionGraphManager bound to your function graph.
Definition at line 40 of file multiDimFunctionGraphManager_tpl.h.
|
virtual |
Class destructor.
Definition at line 49 of file multiDimFunctionGraphManager_tpl.h.
|
private |
Swap two adjacent variable.
Order is important here. X must precede Y before the swap (at the end Y will then precede X). Not respecting this constraint leads to unattended behaviour.
x | The first variable to swap. |
y | The second variable to swap. |
Definition at line 290 of file multiDimFunctionGraphManager_tpl.h.
|
private |
Checks if a similar node does not already exists in the graph.
Tow nodes are similar if for every value assumed by the associated variable, these two nodes have the same children.
var | The node to check for. |
sons | The node sons. |
Definition at line 440 of file multiDimFunctionGraphManager_tpl.h.
|
private |
Checks if node has the same child for every variable value.
var | The node to check for. |
sons | The node sons. |
Definition at line 464 of file multiDimFunctionGraphManager_tpl.h.
INLINE NodeId gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::addInternalNode | ( | const DiscreteVariable * | var | ) |
Inserts a new non terminal node in graph.
NodeId of this node is generated automatically.
var | Associated variable |
Definition at line 75 of file multiDimFunctionGraphManager_tpl.h.
|
pure virtual |
Inserts a new non terminal node in graph.
NodeId of this node is generated automatically.
var | The associated variable. |
sons | A table of size var->domainSize() containing nodeid of sons nodes. |
OperationNotAllowed | Raised if MultiDimFunctionGraph has no variable yet. |
Implemented in gum::MultiDimFunctionGraphROManager< GUM_SCALAR, TerminalNodePolicy >, and gum::MultiDimFunctionGraphTreeManager< GUM_SCALAR, TerminalNodePolicy >.
INLINE NodeId gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::addInternalNode | ( | const DiscreteVariable * | var, |
NodeId | nid | ||
) |
Inserts a new non terminal node in graph.
NodeId of this node is generated automatically.
var | The ssociated variable. |
nid | The desired id for that node. |
OperationNotAllowed | Raised if MultiDimFunctionGraph has no variable yet. |
Definition at line 62 of file multiDimFunctionGraphManager_tpl.h.
|
protected |
Adds an internal node.
var | The node to add. |
sons | The node sons. |
Definition at line 86 of file multiDimFunctionGraphManager_tpl.h.
INLINE NodeId gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::addTerminalNode | ( | const GUM_SCALAR & | value | ) |
Adds a value to the MultiDimFunctionGraph.
This will create a terminal node, which of id is returned. If a terminal node with such value already exists, its id will be return instead.
value | The value added by copy. |
Definition at line 102 of file multiDimFunctionGraphManager_tpl.h.
INLINE void gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::clean | ( | ) |
Removes var without nodes in the diagram.
Definition at line 537 of file multiDimFunctionGraphManager_tpl.h.
void gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::eraseNode | ( | NodeId | id, |
NodeId | replacingId = 0 , |
||
bool | updateParents = true |
||
) |
Erases a node from the diagram.
id | The id of the variable to erase. |
replacingId | Offers the possibility to reroute any parent to the given node. |
updateParents | Indicates if such remapping has to be done. |
NotFound | Raised if node isn't in diagram. |
Definition at line 115 of file multiDimFunctionGraphManager_tpl.h.
|
protected |
Remaps all arcs going to ou going from the first given node to the second node, then delete first node.
x | The variable from which all arcs are removed. |
y | The variable for which all of x arcs are added. |
Definition at line 392 of file multiDimFunctionGraphManager_tpl.h.
void gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::minimizeSize | ( | ) |
Performs a sifting in search of a(local) minimal size.
Definition at line 204 of file multiDimFunctionGraphManager_tpl.h.
void gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::moveTo | ( | const DiscreteVariable * | x, |
Idx | desiredPos | ||
) |
Changes var position in variable sequence.
x | The varaible to change. |
desiredPos | The new posiition. |
Definition at line 261 of file multiDimFunctionGraphManager_tpl.h.
|
protected |
Check for redundancy.
Checks if a similar node does not already exists in the graph or if it has the same child for every variable value. If no node is a match, this node is added to the graph.
var | The node to add in the graph. |
sonsMap | The node sons. |
Definition at line 419 of file multiDimFunctionGraphManager_tpl.h.
|
pure virtual |
Ensures that every isomorphic subgraphs are merged together.
Implemented in gum::MultiDimFunctionGraphROManager< GUM_SCALAR, TerminalNodePolicy >, and gum::MultiDimFunctionGraphTreeManager< GUM_SCALAR, TerminalNodePolicy >.
|
protected |
Ensures that every isomorphic subgraphs are merged together.
Definition at line 474 of file multiDimFunctionGraphManager_tpl.h.
INLINE void gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::setRootNode | ( | const NodeId & | root | ) |
Sets root node of decision diagram.
root | The node to set as root. |
Definition at line 55 of file multiDimFunctionGraphManager_tpl.h.
INLINE void gum::MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy >::setSon | ( | const NodeId & | node, |
const Idx & | modality, | ||
const NodeId & | sonNode | ||
) |
Sets nodes son for given modality to designated son node.
node | The node to which a node is added. |
modality | The modality for which sonNode is added to node. |
sonNode | The node to add as a son to node. |
Definition at line 162 of file multiDimFunctionGraphManager_tpl.h.
|
friend |
This friend methods from is the only way to get an instance of a manager.
See class description for more info.
|
private |
The multidimdecisiongraph supposed to be edited.
Definition at line 313 of file multiDimFunctionGraphManager.h.