Direct Graphical Models  v.1.5.2
DirectGraphicalModels::CGraph Class Reference

Pairwise graph class. More...

#include <Graph.h>

Inheritance diagram for DirectGraphicalModels::CGraph:
Collaboration diagram for DirectGraphicalModels::CGraph:

Public Member Functions

 CGraph (byte nStates)
 Constructor. More...
 
virtual ~CGraph (void)
 
virtual void reset (void)
 Resets the graph. More...
 
virtual size_t addNode (void)
 Adds an additional node. More...
 
virtual size_t addNode (const Mat &pot)
 Adds an additional node with specified potentional. More...
 
virtual void setNode (size_t node, const Mat &pot)
 Sets or changes the potential of node. More...
 
virtual void getNode (size_t node, Mat &pot) const
 Returns the node potential. More...
 
virtual void getChildNodes (size_t node, vec_size_t &vNodes) const
 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
 Returns the set of IDs of the parent nodes of the argument node. More...
 
virtual void addEdge (size_t srcNode, size_t dstNode)
 Adds an additional directed edge. More...
 
virtual void addEdge (size_t srcNode, size_t dstNode, const Mat &pot)
 Adds an additional directed edge with specified potentional. More...
 
virtual void setEdge (size_t srcNode, size_t dstNode, const Mat &pot)
 Sets or changes the potentional of directed edge. More...
 
virtual void getEdge (size_t srcNode, size_t dstNode, Mat &pot) const
 Returns the edge potential. More...
 
virtual void setEdgeGroup (size_t srcNode, size_t dstNode, byte group)
 Assigns a directed edge (srcNode) –> (dstNode) to the group group. More...
 
virtual byte getEdgeGroup (size_t srcNode, size_t dstNode) const
 Returns the group of the edge. More...
 
virtual void removeEdge (size_t srcNode, size_t dstNode)
 Removes the specified edge. More...
 
virtual bool isEdgeExists (size_t srcNode, size_t dstNode) const
 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...
 
virtual void addArc (size_t Node1, size_t Node2)
 Adds an additional udirected edge (arc) More...
 
virtual void addArc (size_t Node1, size_t Node2, 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...
 
virtual size_t getNumNodes (void) const
 Returns the number of nodes in the graph. More...
 
virtual size_t getNumEdges (void) const
 Returns the number of edges in the graph. More...
 
- Public Member Functions inherited from DirectGraphicalModels::IGraph
 IGraph (byte nStates)
 Constructor. More...
 
virtual ~IGraph (void)
 

Protected Member Functions

virtual void removeEdge (size_t edge)
 Removes the specified edge. More...
 

Friends

class CMessagePassing
 
class CInferExact
 
class CInferChain
 
class CInferTree
 
class CInferLBP
 
class CInferViterbi
 
class CInferTRW
 
class CInferTRW_S
 
class CDecode
 

Additional Inherited Members

- Protected Attributes inherited from DirectGraphicalModels::IGraph
byte m_nStates
 The number of states (classes) More...
 

Detailed Description

Pairwise graph class.

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 72 of file Graph.h.

Constructor & Destructor Documentation

◆ CGraph()

DirectGraphicalModels::CGraph::CGraph ( byte  nStates)
inline

Constructor.

Parameters
nStatesthe number of States (classes)

Definition at line 92 of file Graph.h.

◆ ~CGraph()

virtual DirectGraphicalModels::CGraph::~CGraph ( void  )
inlinevirtual

Definition at line 93 of file Graph.h.

Member Function Documentation

◆ addArc() [1/2]

void DirectGraphicalModels::CGraph::addArc ( size_t  Node1,
size_t  Node2 
)
virtual

Adds an additional udirected edge (arc)

The arc is emulated by adding two directed edges

Parameters
Node1index of the first node
Node2index of the second node

Implements DirectGraphicalModels::IGraph.

Definition at line 176 of file Graph.cpp.

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

◆ addArc() [2/2]

void DirectGraphicalModels::CGraph::addArc ( size_t  Node1,
size_t  Node2,
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
potedge potential matrix: Mat(size: nStates x nStates; type: CV_32FC1)

Implements DirectGraphicalModels::IGraph.

Definition at line 183 of file Graph.cpp.

Here is the call graph for this function:

◆ addEdge() [1/2]

void DirectGraphicalModels::CGraph::addEdge ( size_t  srcNode,
size_t  dstNode 
)
virtual

Adds an additional directed edge.

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node

Implements DirectGraphicalModels::IGraph.

Definition at line 62 of file Graph.cpp.

Here is the caller graph for this function:

◆ addEdge() [2/2]

void DirectGraphicalModels::CGraph::addEdge ( size_t  srcNode,
size_t  dstNode,
const Mat &  pot 
)
virtual

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)

Implements DirectGraphicalModels::IGraph.

Definition at line 81 of file Graph.cpp.

◆ addNode() [1/2]

size_t DirectGraphicalModels::CGraph::addNode ( void  )
virtual

Adds an additional node.

Returns
the node's ID

Implements DirectGraphicalModels::IGraph.

Definition at line 14 of file Graph.cpp.

Here is the caller graph for this function:

◆ addNode() [2/2]

size_t DirectGraphicalModels::CGraph::addNode ( const Mat &  pot)
virtual

Adds an additional node with specified potentional.

Parameters
potnode potential vector: Mat(size: nStates x 1; type: CV_32FC1)
Returns
the node's ID

Implements DirectGraphicalModels::IGraph.

Definition at line 21 of file Graph.cpp.

◆ getChildNodes()

void DirectGraphicalModels::CGraph::getChildNodes ( size_t  node,
vec_size_t &  vNodes 
) const
virtual

Returns the set of IDs of the child nodes of the argument node.

Parameters
[in]nodenode index
[out]vNodesvector with the child node's ID

Implements DirectGraphicalModels::IGraph.

Definition at line 46 of file Graph.cpp.

Here is the caller graph for this function:

◆ getEdge()

void DirectGraphicalModels::CGraph::getEdge ( size_t  srcNode,
size_t  dstNode,
Mat &  pot 
) const
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

Implements DirectGraphicalModels::IGraph.

Definition at line 113 of file Graph.cpp.

Here is the caller graph for this function:

◆ getEdgeGroup()

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

Returns the group of the edge.

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

Implements DirectGraphicalModels::IGraph.

Definition at line 136 of file Graph.cpp.

Here is the caller graph for this function:

◆ getNode()

void DirectGraphicalModels::CGraph::getNode ( size_t  node,
Mat &  pot 
) const
virtual

Returns the node potential.

Parameters
[in]nodenode index
[out]potnode potential vector: Mat(size: nStates x 1; type: CV_32FC1)

Implements DirectGraphicalModels::IGraph.

Definition at line 38 of file Graph.cpp.

Here is the caller graph for this function:

◆ getNumEdges()

virtual size_t DirectGraphicalModels::CGraph::getNumEdges ( void  ) const
inlinevirtual

Returns the number of edges in the graph.

Returns
number of edges

Implements DirectGraphicalModels::IGraph.

Definition at line 121 of file Graph.h.

◆ getNumNodes()

virtual size_t DirectGraphicalModels::CGraph::getNumNodes ( void  ) const
inlinevirtual

Returns the number of nodes in the graph.

Returns
number of nodes

Implements DirectGraphicalModels::IGraph.

Definition at line 120 of file Graph.h.

Here is the caller graph for this function:

◆ getParentNodes()

void DirectGraphicalModels::CGraph::getParentNodes ( size_t  node,
vec_size_t &  vNodes 
) const
virtual

Returns the set of IDs of the parent nodes of the argument node.

Parameters
[in]nodenode index
[out]vNodesvector with the parent node's ID

Implements DirectGraphicalModels::IGraph.

Definition at line 54 of file Graph.cpp.

Here is the caller graph for this function:

◆ isArcExists()

bool DirectGraphicalModels::CGraph::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

Implements DirectGraphicalModels::IGraph.

Definition at line 214 of file Graph.cpp.

Here is the call graph for this function:

◆ isEdgeArc()

bool DirectGraphicalModels::CGraph::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

Implements DirectGraphicalModels::IGraph.

Definition at line 170 of file Graph.cpp.

Here is the call graph for this function:

◆ isEdgeExists()

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

Checks whether the edge exists.

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

Implements DirectGraphicalModels::IGraph.

Definition at line 159 of file Graph.cpp.

Here is the caller graph for this function:

◆ removeArc()

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

Removes the specified arc.

Parameters
Node1index of the first node
Node2index of the second node

Implements DirectGraphicalModels::IGraph.

Definition at line 208 of file Graph.cpp.

Here is the call graph for this function:

◆ removeEdge() [1/2]

void DirectGraphicalModels::CGraph::removeEdge ( size_t  srcNode,
size_t  dstNode 
)
virtual

Removes the specified edge.

Parameters
srcNodeindex of the source node
dstNodeindex of the destination node

Implements DirectGraphicalModels::IGraph.

Definition at line 147 of file Graph.cpp.

Here is the caller graph for this function:

◆ removeEdge() [2/2]

void DirectGraphicalModels::CGraph::removeEdge ( size_t  edge)
protectedvirtual

Removes the specified edge.

Parameters
edgeindex of the edge
Todo:
Optimize the edge removement

Definition at line 221 of file Graph.cpp.

◆ reset()

void DirectGraphicalModels::CGraph::reset ( void  )
virtual

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::IGraph.

Definition at line 6 of file Graph.cpp.

Here is the caller graph for this function:

◆ setArc()

void DirectGraphicalModels::CGraph::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)

Implements DirectGraphicalModels::IGraph.

Definition at line 193 of file Graph.cpp.

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

◆ setArcGroup()

void DirectGraphicalModels::CGraph::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

Implements DirectGraphicalModels::IGraph.

Definition at line 202 of file Graph.cpp.

Here is the call graph for this function:

◆ setEdge()

void DirectGraphicalModels::CGraph::setEdge ( size_t  srcNode,
size_t  dstNode,
const Mat &  pot 
)
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)

Implements DirectGraphicalModels::IGraph.

Definition at line 100 of file Graph.cpp.

Here is the caller graph for this function:

◆ setEdgeGroup()

void DirectGraphicalModels::CGraph::setEdgeGroup ( size_t  srcNode,
size_t  dstNode,
byte  group 
)
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

Implements DirectGraphicalModels::IGraph.

Definition at line 126 of file Graph.cpp.

Here is the caller graph for this function:

◆ setNode()

void DirectGraphicalModels::CGraph::setNode ( size_t  node,
const Mat &  pot 
)
virtual

Sets or changes the potential of node.

Parameters
nodenode index
potnode potential vector: Mat(size: nStates x 1; type: CV_32FC1)

Implements DirectGraphicalModels::IGraph.

Definition at line 28 of file Graph.cpp.

Friends And Related Function Documentation

◆ CDecode

friend class CDecode
friend

Definition at line 84 of file Graph.h.

◆ CInferChain

friend class CInferChain
friend

Definition at line 77 of file Graph.h.

◆ CInferExact

friend class CInferExact
friend

Definition at line 76 of file Graph.h.

◆ CInferLBP

friend class CInferLBP
friend

Definition at line 79 of file Graph.h.

◆ CInferTree

friend class CInferTree
friend

Definition at line 78 of file Graph.h.

◆ CInferTRW

friend class CInferTRW
friend

Definition at line 81 of file Graph.h.

◆ CInferTRW_S

friend class CInferTRW_S
friend

Definition at line 82 of file Graph.h.

◆ CInferViterbi

friend class CInferViterbi
friend

Definition at line 80 of file Graph.h.

◆ CMessagePassing

friend class CMessagePassing
friend

Definition at line 74 of file Graph.h.


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