2 #include "GraphPairwise.h" 15 edge->suspend =
false;
19 size_t * nFromEdges =
new size_t[nNodes];
20 std::deque<size_t> nodeQueue;
22 nFromEdges[node->id] = node->from.size();
23 if (nFromEdges[node->id] <= 1) nodeQueue.push_back(node->id);
27 float *temp =
new float[nStates];
28 while (!nodeQueue.empty()) {
31 size_t n = nodeQueue.front();
32 nodeQueue.pop_front();
35 size_t nToEdges = node->
to.size();
37 bool allSuspend =
true;
38 for (
size_t e_t = 0; e_t < nToEdges; e_t++) {
47 for (
size_t e_t = 0; e_t < nToEdges; e_t++) {
49 if (edge_to->
msg)
continue;
53 size_t n2 = edge_to->
node2;
55 if (nFromEdges[n2] <= 1) nodeQueue.push_back(n2);
58 for (
size_t e_t = 0; e_t < nToEdges; e_t++) {
61 if (edge_to->
msg)
continue;
65 size_t n2 = edge_to->
node2;
67 if (nFromEdges[n2] <= 1) nodeQueue.push_back(n2);
vec_size_t to
Array of edge ids, pointing to the Child vertices.
byte getNumStates(void) const
Returns number of states (classes)
bool suspend
Flag, indicating weather the message calculation must be postponed (used in message-passing algorithm...
size_t node2
Second (destination) node in edge.
float * msg
Message (used in message-passing algorithms): Mat(size: nStates x 1; type: CV_32FC1) ...
virtual void calculateMessages(unsigned int nIt)
Calculates messages for exact inference in a tree graph.
virtual size_t getNumNodes(void) const =0
Returns the number of nodes in the graph.
CGraph & getGraph(void) const
Returns the reference to the graph.
std::unique_ptr< Node > ptr_node_t
CGraphPairwise & getGraphPairwise(void) const
Returns the graph.
std::unique_ptr< Edge > ptr_edge_t
void calculateMessage(Edge *edge, float *temp, float *&dst, bool maxSum=false)
Calculates one message for the specified edge edge.