![]() |
Direct Graphical Models
v.1.7.0
|
Pairwise graph class. More...
#include <GraphWeiss.h>
Classes | |
struct | Edge |
Edge structure More... | |
struct | Node |
Node structure More... | |
Public Types | |
using | vec_pEdge_t = std::vector< Edge * > |
using | vec_pNode_t = std::vector< Node * > |
Public Member Functions | |
CGraphWeiss (byte nStates) | |
Constructor. More... | |
virtual | ~CGraphWeiss (void) |
void | reset (void) override |
Resets the graph. More... | |
size_t | addNode (const Mat &pot=EmptyMat) override |
Adds an additional node (with specified potentional) More... | |
void | setNode (size_t node, const Mat &pot) override |
Sets or changes the potential of node. More... | |
void | getNode (size_t node, Mat &pot) const override |
Returns the node potential. More... | |
void | getChildNodes (size_t node, vec_size_t &vNodes) const override |
Returns the set of IDs of the child nodes of the argument node. More... | |
void | getParentNodes (size_t node, vec_size_t &vNodes) const override |
Returns the set of IDs of the parent nodes of the argument node. More... | |
size_t | getNumNodes (void) const override |
Returns the number of nodes in the graph. More... | |
size_t | getNumEdges (void) const override |
Returns the number of edges in the graph. More... | |
void | addEdge (size_t srcNode, size_t dstNode, byte group, const Mat &pot) override |
Adds an additional directed edge with specified potentional. More... | |
void | setEdge (size_t srcNode, size_t dstNode, const Mat &pot) override |
Sets or changes the potentional of directed edge. More... | |
void | setEdges (std::optional< byte > group, const Mat &pot) override |
Sets the potential pot to all edges belonging to group group. More... | |
void | getEdge (size_t srcNode, size_t dstNode, Mat &pot) const override |
Returns the edge potential. More... | |
void | setEdgeGroup (size_t srcNode, size_t dstNode, byte group) override |
Assigns a directed edge (srcNode) –> (dstNode) to the group group. More... | |
byte | getEdgeGroup (size_t srcNode, size_t dstNode) const override |
Returns the group of the edge. More... | |
void | removeEdge (size_t srcNode, size_t dstNode) override |
Removes the specified edge. More... | |
bool | isEdgeExists (size_t srcNode, size_t dstNode) const override |
Checks whether the edge exists. More... | |
![]() | |
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 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... | |
![]() | |
CGraph (byte nStates) | |
Constructor. More... | |
CGraph (const CGraph &)=delete | |
virtual | ~CGraph (void)=default |
const CGraph & | operator= (const CGraph &)=delete |
virtual void | addNodes (const Mat &pots) |
Adds the graph nodes with potentials. More... | |
virtual void | setNodes (size_t start_node, const Mat &pots) |
Fills the graph nodes with new potentials. More... | |
virtual void | getNodes (size_t start_node, size_t num_nodes, Mat &pots) const |
Returns the node potentials. More... | |
byte | getNumStates (void) const |
Returns number of states (classes) More... | |
Protected Member Functions | |
Edge * | findEdge (size_t srcNode, size_t dstNode) const |
Finds and returns the Edge defined by two nodes. More... | |
Private Attributes | |
size_t | m_IDx |
vec_pNode_t | m_vpNodes |
Pairwise graph class.
Implementation is based on M. A. Weiss recommendations
Definition at line 18 of file GraphWeiss.h.
using DirectGraphicalModels::CGraphWeiss::vec_pEdge_t = std::vector<Edge *> |
Definition at line 52 of file GraphWeiss.h.
using DirectGraphicalModels::CGraphWeiss::vec_pNode_t = std::vector<Node *> |
Definition at line 74 of file GraphWeiss.h.
DirectGraphicalModels::CGraphWeiss::CGraphWeiss | ( | byte | nStates | ) |
Constructor.
nStates | the number of States (classes) |
Definition at line 7 of file GraphWeiss.cpp.
|
virtual |
Definition at line 13 of file GraphWeiss.cpp.
|
overridevirtual |
Adds an additional directed edge with specified potentional.
srcNode | index of the source node |
dstNode | index of the destination node |
group | The edge group ID |
pot | Edge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1) |
Implements DirectGraphicalModels::IGraphPairwise.
Definition at line 87 of file GraphWeiss.cpp.
|
overridevirtual |
Adds an additional node (with specified potentional)
pot | node potential vector: Mat(size: nStates x 1; type: CV_32FC1) |
Implements DirectGraphicalModels::CGraph.
Definition at line 31 of file GraphWeiss.cpp.
|
protected |
Finds and returns the Edge defined by two nodes.
srcNode | index of the source node |
dstNode | index of the destination node |
Definition at line 193 of file GraphWeiss.cpp.
|
overridevirtual |
Returns the set of IDs of the child nodes of the argument node.
[in] | node | node index |
[out] | vNodes | vector with the child node's ID |
Implements DirectGraphicalModels::CGraph.
Definition at line 59 of file GraphWeiss.cpp.
|
overridevirtual |
Returns the edge potential.
[in] | srcNode | index of the source node |
[in] | dstNode | index of the destination node |
[out] | pot | edge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1) if exists, empty Mat otherwise |
Implements DirectGraphicalModels::IGraphPairwise.
Definition at line 127 of file GraphWeiss.cpp.
|
overridevirtual |
Returns the group of the edge.
srcNode | index of the source node |
dstNode | index of the destination node |
Implements DirectGraphicalModels::IGraphPairwise.
Definition at line 151 of file GraphWeiss.cpp.
|
overridevirtual |
Returns the node potential.
[in] | node | node index |
[out] | pot | node potential vector: Mat(size: nStates x 1; type: CV_32FC1) |
Implements DirectGraphicalModels::CGraph.
Definition at line 49 of file GraphWeiss.cpp.
|
overridevirtual |
Returns the number of edges in the graph.
Implements DirectGraphicalModels::CGraph.
Definition at line 78 of file GraphWeiss.cpp.
|
inlineoverridevirtual |
Returns the number of nodes in the graph.
Implements DirectGraphicalModels::CGraph.
Definition at line 92 of file GraphWeiss.h.
|
overridevirtual |
Returns the set of IDs of the parent nodes of the argument node.
[in] | node | node index |
[out] | vNodes | vector with the parent node's ID |
Implements DirectGraphicalModels::CGraph.
Definition at line 69 of file GraphWeiss.cpp.
|
overridevirtual |
Checks whether the edge exists.
srcNode | index of the source node |
dstNode | index of the destination node |
true | if the edge exists |
false | otherwise |
Implements DirectGraphicalModels::IGraphPairwise.
Definition at line 184 of file GraphWeiss.cpp.
|
overridevirtual |
Removes the specified edge.
srcNode | index of the source node |
dstNode | index of the destination node |
Implements DirectGraphicalModels::IGraphPairwise.
Definition at line 163 of file GraphWeiss.cpp.
|
overridevirtual |
Resets the graph.
This function allows to re-use the graph or update node potential, while preserving the graph structure. It deletes all the nodes and edges and sets node index to zero.
Implements DirectGraphicalModels::CGraph.
Definition at line 21 of file GraphWeiss.cpp.
|
overridevirtual |
Sets or changes the potentional of directed edge.
srcNode | index of the source node |
dstNode | index of the destination node |
pot | Edge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1) |
Implements DirectGraphicalModels::IGraphPairwise.
Definition at line 106 of file GraphWeiss.cpp.
|
overridevirtual |
Assigns a directed edge (srcNode) –> (dstNode) to the group group.
srcNode | index of the source node |
dstNode | index of the destination node |
group | The edge group ID |
Implements DirectGraphicalModels::IGraphPairwise.
Definition at line 139 of file GraphWeiss.cpp.
|
overridevirtual |
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()
group | The edge group ID. This argument is optional, and if it is not set, this function will set potential to all existing edges |
pot | Edge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1) |
Implements DirectGraphicalModels::IGraphPairwise.
Definition at line 118 of file GraphWeiss.cpp.
|
overridevirtual |
Sets or changes the potential of node.
node | node index |
pot | node potential vector: Mat(size: nStates x 1; type: CV_32FC1) |
Implements DirectGraphicalModels::CGraph.
Definition at line 39 of file GraphWeiss.cpp.
|
private |
Definition at line 115 of file GraphWeiss.h.
|
private |
Definition at line 116 of file GraphWeiss.h.