5 #include "IGraphPairwise.h" 22 Node(
size_t _id,
const Mat &p = EmptyMat) :
id(_id),
Pot(p.empty() ? Mat() : p.clone()),
sol(0) {}
83 DllExport
void reset(
void)
override;
84 DllExport
size_t addNode (
const Mat &pot = EmptyMat)
override;
85 DllExport
void setNode (
size_t node,
const Mat &pot)
override;
86 DllExport
void getNode (
size_t node, Mat &pot)
const override;
87 DllExport
void getChildNodes (
size_t node, vec_size_t &vNodes)
const override;
88 DllExport
void getParentNodes(
size_t node, vec_size_t &vNodes)
const override;
94 DllExport
void addEdge (
size_t srcNode,
size_t dstNode, byte group,
const Mat &pot)
override;
95 DllExport
void setEdge (
size_t srcNode,
size_t dstNode,
const Mat &pot)
override;
96 DllExport
void setEdges (std::optional<byte> group,
const Mat& pot)
override;
97 DllExport
void getEdge (
size_t srcNode,
size_t dstNode, Mat &pot)
const override;
98 DllExport
void setEdgeGroup(
size_t srcNode,
size_t dstNode, byte group)
override;
99 DllExport byte
getEdgeGroup(
size_t srcNode,
size_t dstNode)
const override;
100 DllExport
void removeEdge (
size_t srcNode,
size_t dstNode)
override;
101 DllExport
bool isEdgeExists(
size_t srcNode,
size_t dstNode)
const override;
Mat Pot
Node potentials: Mat(size: nStates x 1; type: CV_32FC1)
void setEdges(std::optional< byte > group, const Mat &pot) override
Sets the potential pot to all edges belonging to group group.
vec_size_t to
Array of edge ids, pointing to the Child vertices.
virtual ~CGraphPairwise(void)=default
void removeEdge(size_t srcNode, size_t dstNode) override
Removes the specified edge.
void addEdge(size_t srcNode, size_t dstNode, byte group, const Mat &pot) override
Adds an additional directed edge with specified potentional.
void setNode(size_t node, const Mat &pot) override
Sets or changes the potential of node.
bool suspend
Flag, indicating weather the message calculation must be postponed (used in message-passing algorithm...
size_t node2
Second (destination) node in edge.
Abstract base class for message passing inference algorithmes.
CGraphPairwise(byte nStates)
Constructor.
std::vector< ptr_node_t > vec_node_t
float * msg
Message (used in message-passing algorithms): Mat(size: nStates x 1; type: CV_32FC1) ...
byte getEdgeGroup(size_t srcNode, size_t dstNode) const override
Returns the group of the edge.
std::vector< ptr_edge_t > vec_edge_t
size_t node1
First (source) node in edge.
float * msg_temp
Temp Message (used in message-passing algorithms): Mat(size: nStates x 1; type: CV_32FC1) ...
Inference for chain graphs.
void setEdgeGroup(size_t srcNode, size_t dstNode, byte group) override
Assigns a directed edge (srcNode) –> (dstNode) to the group group.
byte group_id
ID of the group, to which the edge belongs.
Tree-reweighted inference class.
void reset(void) override
Resets the graph.
bool isEdgeExists(size_t srcNode, size_t dstNode) const override
Checks whether the edge exists.
size_t getNumEdges(void) const override
Returns the number of edges in the graph.
size_t getNumNodes(void) const override
Returns the number of nodes in the graph.
Edge(size_t n1, size_t n2, byte group=0, const Mat &p=EmptyMat)
std::unique_ptr< Node > ptr_node_t
void getChildNodes(size_t node, vec_size_t &vNodes) const override
Returns the set of IDs of the child nodes of the argument node.
void getParentNodes(size_t node, vec_size_t &vNodes) const override
Returns the set of IDs of the parent nodes of the argument node.
void getNode(size_t node, Mat &pot) const override
Returns the node potential.
Inference for tree graphs (undirected graphs without loops)
void setEdge(size_t srcNode, size_t dstNode, const Mat &pot) override
Sets or changes the potentional of directed edge.
Interface class for graphical models.
Mat Pot
The edge potentials: Mat(size: nStates x nStates; type: CV_32FC1)
std::unique_ptr< Edge > ptr_edge_t
Max product Viterbi inference class.
Sum product Loopy Belief Propagation inference class.
void getEdge(size_t srcNode, size_t dstNode, Mat &pot) const override
Returns the edge potential.
vec_size_t from
Array of edge ids, coming from the Parent vertices.
Node(size_t _id, const Mat &p=EmptyMat)
size_t addNode(const Mat &pot=EmptyMat) override
Adds an additional node (with specified potentional)