Direct Graphical Models  v.1.7.0
DirectGraphicalModels::IGraphPairwise Class Referenceabstract

Interface class for graphical models. More...

#include <IGraphPairwise.h>

Inheritance diagram for DirectGraphicalModels::IGraphPairwise:
Collaboration diagram for DirectGraphicalModels::IGraphPairwise:

Public Member Functions

 IGraphPairwise (byte nStates)
 Constructor. More...
 
virtual ~IGraphPairwise (void)=default
 
void marginalize (const vec_size_t &nodes)
 Marginalizes a set of nodes. More...
 
void addEdge (size_t srcNode, size_t dstNode, const Mat &pot=EmptyMat)
 Adds an additional directed edge with specified potentional. More...
 
virtual void addEdge (size_t srcNode, size_t dstNode, byte group, const Mat &pot)=0
 Adds an additional directed edge with specified potentional. More...
 
virtual void setEdge (size_t srcNode, size_t dstNode, const Mat &pot)=0
 Sets or changes the potentional of directed edge. More...
 
virtual void setEdges (std::optional< byte > group, const Mat &pot)=0
 Sets the potential pot to all edges belonging to group group. More...
 
virtual void getEdge (size_t srcNode, size_t dstNode, Mat &pot) const =0
 Returns the edge potential. More...
 
virtual void setEdgeGroup (size_t srcNode, size_t dstNode, byte group)=0
 Assigns a directed edge (srcNode) –> (dstNode) to the group group. More...
 
virtual byte getEdgeGroup (size_t srcNode, size_t dstNode) const =0
 Returns the group of the edge. More...
 
virtual void removeEdge (size_t srcNode, size_t dstNode)=0
 Removes the specified edge. More...
 
virtual bool isEdgeExists (size_t srcNode, size_t dstNode) const =0
 Checks whether the edge exists. More...
 
virtual bool isEdgeArc (size_t srcNode, size_t dstNode) const
 Checks whether the edge is a part of an arc. More...
 
void addArc (size_t Node1, size_t Node2, const Mat &pot=EmptyMat)
 Adds an additional udirected edge (arc) with specified potentional. More...
 
virtual void addArc (size_t Node1, size_t Node2, byte group, const Mat &pot)
 Adds an additional udirected edge (arc) with specified potentional. More...
 
virtual void setArc (size_t Node1, size_t Node2, const Mat &pot)
 Sets or changes the potentional of udirected edge (arc) More...
 
virtual void setArcGroup (size_t Node1, size_t Node2, byte group)
 Assigns an undirected edge (arc) (Node1) – (Node2) to the group group. More...
 
virtual void removeArc (size_t Node1, size_t Node2)
 Removes the specified arc. More...
 
virtual bool isArcExists (size_t Node1, size_t Node2) const
 Checks whether the arc exists. More...
 
- Public Member Functions inherited from DirectGraphicalModels::CGraph
 CGraph (byte nStates)
 Constructor. More...
 
 CGraph (const CGraph &)=delete
 
virtual ~CGraph (void)=default
 
const CGraphoperator= (const CGraph &)=delete
 
virtual void reset (void)=0
 Resets the graph. More...
 
virtual size_t addNode (const Mat &pot=EmptyMat)=0
 Adds an additional node (with specified potentional) More...
 
virtual void addNodes (const Mat &pots)
 Adds the graph nodes with potentials. More...
 
virtual void setNode (size_t node, const Mat &pot)=0
 Sets or changes the potential of node. More...
 
virtual void setNodes (size_t start_node, const Mat &pots)
 Fills the graph nodes with new potentials. More...
 
virtual void getNode (size_t node, Mat &pot) const =0
 Returns the node potential. More...
 
virtual void getNodes (size_t start_node, size_t num_nodes, Mat &pots) const
 Returns the node potentials. More...
 
virtual void getChildNodes (size_t node, vec_size_t &vNodes) const =0
 Returns the set of IDs of the child nodes of the argument node. More...
 
virtual void getParentNodes (size_t node, vec_size_t &vNodes) const =0
 Returns the set of IDs of the parent nodes of the argument node. More...
 
virtual size_t getNumNodes (void) const =0
 Returns the number of nodes in the graph. More...
 
virtual size_t getNumEdges (void) const =0
 Returns the number of edges in the graph. More...
 
byte getNumStates (void) const
 Returns number of states (classes) More...
 

Detailed Description

Interface class for graphical models.

Author
Sergey G. Kosov, serge.nosp@m.y.ko.nosp@m.sov@p.nosp@m.roje.nosp@m.ct-10.nosp@m..de

Definition at line 15 of file IGraphPairwise.h.

Constructor & Destructor Documentation

◆ IGraphPairwise()

DirectGraphicalModels::IGraphPairwise::IGraphPairwise ( byte  nStates)
inline

Constructor.

Parameters
nStatesthe number of States (classes)

Definition at line 22 of file IGraphPairwise.h.

◆ ~IGraphPairwise()

virtual DirectGraphicalModels::IGraphPairwise::~IGraphPairwise ( void  )
virtualdefault

Member Function Documentation

◆ addArc() [1/2]

void DirectGraphicalModels::IGraphPairwise::addArc ( size_t  Node1,
size_t  Node2,
const Mat &  pot = EmptyMat 
)

Adds an additional udirected edge (arc) with specified potentional.

The arc is emulated by adding two directed edges. For sake of consistency the pot matrix here is squarerooted:

addEdge(Node1, Node2, sqrt(pot));
addEdge(Node2, Node1, sqrt(pot));
Parameters
Node1index of the first node
Node2index of the second node
potedge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)

Definition at line 16 of file IGraphPairwise.cpp.

Here is the caller graph for this function:

◆ addArc() [2/2]

void DirectGraphicalModels::IGraphPairwise::addArc ( size_t  Node1,
size_t  Node2,
byte  group,
const Mat &  pot 
)
virtual

Adds an additional udirected edge (arc) with specified potentional.

The arc is emulated by adding two directed edges. For sake of consistency the pot matrix here is squarerooted:

addEdge(Node1, Node2, sqrt(pot));
addEdge(Node2, Node1, sqrt(pot));
Parameters
Node1index of the first node
Node2index of the second node
groupThe edge group ID
potedge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)

Definition at line 22 of file IGraphPairwise.cpp.

Here is the call graph for this function:

◆ addEdge() [1/2]

void DirectGraphicalModels::IGraphPairwise::addEdge ( size_t  srcNode,
size_t  dstNode,
const Mat &  pot = EmptyMat 
)

Adds an additional directed edge with specified potentional.

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node
potEdge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)

Definition at line 5 of file IGraphPairwise.cpp.

Here is the caller graph for this function:

◆ addEdge() [2/2]

virtual void DirectGraphicalModels::IGraphPairwise::addEdge ( size_t  srcNode,
size_t  dstNode,
byte  group,
const Mat &  pot 
)
pure virtual

Adds an additional directed edge with specified potentional.

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node
groupThe edge group ID
potEdge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)

Implemented in DirectGraphicalModels::CGraphWeiss, and DirectGraphicalModels::CGraphPairwise.

◆ getEdge()

virtual void DirectGraphicalModels::IGraphPairwise::getEdge ( size_t  srcNode,
size_t  dstNode,
Mat &  pot 
) const
pure virtual

Returns the edge potential.

Parameters
[in]srcNodeindex of the source node
[in]dstNodeindex of the destination node
[out]potedge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1) if exists, empty Mat otherwise

Implemented in DirectGraphicalModels::CGraphWeiss, and DirectGraphicalModels::CGraphPairwise.

Here is the caller graph for this function:

◆ getEdgeGroup()

virtual byte DirectGraphicalModels::IGraphPairwise::getEdgeGroup ( size_t  srcNode,
size_t  dstNode 
) const
pure virtual

Returns the group of the edge.

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node
Returns
The edge group ID

Implemented in DirectGraphicalModels::CGraphWeiss, and DirectGraphicalModels::CGraphPairwise.

Here is the caller graph for this function:

◆ isArcExists()

bool DirectGraphicalModels::IGraphPairwise::isArcExists ( size_t  Node1,
size_t  Node2 
) const
virtual

Checks whether the arc exists.

Parameters
Node1index of the first node
Node2index of the second node
Return values
trueif the arc exists
falseotherwise

Definition at line 57 of file IGraphPairwise.cpp.

Here is the call graph for this function:

◆ isEdgeArc()

bool DirectGraphicalModels::IGraphPairwise::isEdgeArc ( size_t  srcNode,
size_t  dstNode 
) const
virtual

Checks whether the edge is a part of an arc.

In contrast to the isArcExists() function, this function does not checks whether the input edge exists, and thus faster

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node
Return values
trueif the edge is a part of an arc
falseotherwise

Definition at line 10 of file IGraphPairwise.cpp.

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

◆ isEdgeExists()

virtual bool DirectGraphicalModels::IGraphPairwise::isEdgeExists ( size_t  srcNode,
size_t  dstNode 
) const
pure virtual

Checks whether the edge exists.

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node
Return values
trueif the edge exists
falseotherwise

Implemented in DirectGraphicalModels::CGraphWeiss, and DirectGraphicalModels::CGraphPairwise.

Here is the caller graph for this function:

◆ marginalize()

void DirectGraphicalModels::IGraphPairwise::marginalize ( const vec_size_t &  nodes)

Marginalizes a set of nodes.

This function separates the marginalized graph nodes by removing all the edges connecting them with the remaining nodes. New edges are added if they correspond to the inducing pathes. The potentials of new esges are calculated as the sum of edge potentials from the corresponding inducing path.

This functions operates with inducing pathes with maximal length of 3 nodes.

Parameters
nodesSet of nodes to be marginalized out from the graph

Definition at line 62 of file IGraphPairwise.cpp.

Here is the call graph for this function:

◆ removeArc()

void DirectGraphicalModels::IGraphPairwise::removeArc ( size_t  Node1,
size_t  Node2 
)
virtual

Removes the specified arc.

Parameters
Node1index of the first node
Node2index of the second node

Definition at line 51 of file IGraphPairwise.cpp.

Here is the call graph for this function:

◆ removeEdge()

virtual void DirectGraphicalModels::IGraphPairwise::removeEdge ( size_t  srcNode,
size_t  dstNode 
)
pure virtual

Removes the specified edge.

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node

Implemented in DirectGraphicalModels::CGraphWeiss, and DirectGraphicalModels::CGraphPairwise.

Here is the caller graph for this function:

◆ setArc()

void DirectGraphicalModels::IGraphPairwise::setArc ( size_t  Node1,
size_t  Node2,
const Mat &  pot 
)
virtual

Sets or changes the potentional of udirected edge (arc)

The arc is emulated by adding two directed edges. For sake of consistency the pot matrix here is squarerooted:

addEdge(Node1, Node2, sqrt(pot));
addEdge(Node2, Node1, sqrt(pot));
Parameters
Node1index of the first node
Node2index of the second node
potedge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)

Definition at line 37 of file IGraphPairwise.cpp.

Here is the call graph for this function:

◆ setArcGroup()

void DirectGraphicalModels::IGraphPairwise::setArcGroup ( size_t  Node1,
size_t  Node2,
byte  group 
)
virtual

Assigns an undirected edge (arc) (Node1) – (Node2) to the group group.

Parameters
Node1index of the source node
Node2index of the destination node
groupThe edge group ID

Definition at line 45 of file IGraphPairwise.cpp.

Here is the call graph for this function:

◆ setEdge()

virtual void DirectGraphicalModels::IGraphPairwise::setEdge ( size_t  srcNode,
size_t  dstNode,
const Mat &  pot 
)
pure virtual

Sets or changes the potentional of directed edge.

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node
potEdge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)

Implemented in DirectGraphicalModels::CGraphWeiss, and DirectGraphicalModels::CGraphPairwise.

Here is the caller graph for this function:

◆ setEdgeGroup()

virtual void DirectGraphicalModels::IGraphPairwise::setEdgeGroup ( size_t  srcNode,
size_t  dstNode,
byte  group 
)
pure virtual

Assigns a directed edge (srcNode) –> (dstNode) to the group group.

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node
groupThe edge group ID

Implemented in DirectGraphicalModels::CGraphWeiss, and DirectGraphicalModels::CGraphPairwise.

Here is the caller graph for this function:

◆ setEdges()

virtual void DirectGraphicalModels::IGraphPairwise::setEdges ( std::optional< byte >  group,
const Mat &  pot 
)
pure virtual

Sets the potential pot to all edges belonging to group group.

This function assigns the same potential matrix to all the edges in graph with group property equal to group. By default all edges have group 0. This mightbe changes with functon setEdgeGroup()

Parameters
groupThe edge group ID. This argument is optional, and if it is not set, this function will set potential to all existing edges
potEdge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)

Implemented in DirectGraphicalModels::CGraphWeiss, and DirectGraphicalModels::CGraphPairwise.

Here is the caller graph for this function:

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