Direct Graphical Models  v.1.7.0
Graph.h
1 // Graph interface class;
2 // Written by Sergey Kosov in 2015 for Project X
3 #pragma once
4 
5 #include "types.h"
6 
7 namespace DirectGraphicalModels {
8  // ================================ Graph Interface Class ================================
14  class CGraph
15  {
16  public:
21  DllExport CGraph(byte nStates) : m_nStates(nStates) {};
22  DllExport CGraph(const CGraph&) = delete;
23  DllExport virtual ~CGraph(void) = default;
24 
25  const CGraph& operator= (const CGraph&) = delete;
26 
32  DllExport virtual void reset(void) = 0;
38  DllExport virtual size_t addNode(const Mat &pot = EmptyMat) = 0;
43  DllExport virtual void addNodes(const Mat &pots);
49  DllExport virtual void setNode(size_t node, const Mat &pot) = 0;
57  DllExport virtual void setNodes(size_t start_node, const Mat &pots);
63  DllExport virtual void getNode(size_t node, Mat &pot) const = 0;
72  DllExport virtual void getNodes(size_t start_node, size_t num_nodes, Mat &pots) const;
78  DllExport virtual void getChildNodes(size_t node, vec_size_t &vNodes) const = 0;
84  DllExport virtual void getParentNodes(size_t node, vec_size_t &vNodes) const = 0;
89  DllExport virtual size_t getNumNodes(void) const = 0;
94  DllExport virtual size_t getNumEdges(void) const = 0;
99  DllExport byte getNumStates(void) const { return m_nStates; }
100 
101 
102  private:
103  byte m_nStates;
104  };
105 }
virtual void setNode(size_t node, const Mat &pot)=0
Sets or changes the potential of node.
virtual size_t addNode(const Mat &pot=EmptyMat)=0
Adds an additional node (with specified potentional)
byte getNumStates(void) const
Returns number of states (classes)
Definition: Graph.h:99
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.
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.
virtual size_t getNumEdges(void) const =0
Returns the number of edges in the graph.
virtual size_t getNumNodes(void) const =0
Returns the number of nodes in the graph.
virtual void addNodes(const Mat &pots)
Adds the graph nodes with potentials.
Definition: Graph.cpp:6
virtual void getNode(size_t node, Mat &pot) const =0
Returns the node potential.
Interface class for graphical models.
Definition: Graph.h:14
const CGraph & operator=(const CGraph &)=delete
virtual ~CGraph(void)=default
virtual void getNodes(size_t start_node, size_t num_nodes, Mat &pots) const
Returns the node potentials.
Definition: Graph.cpp:30
virtual void reset(void)=0
Resets the graph.
byte m_nStates
The number of states (classes)
Definition: Graph.h:103
virtual void setNodes(size_t start_node, const Mat &pots)
Fills the graph nodes with new potentials.
Definition: Graph.cpp:11
CGraph(byte nStates)
Constructor.
Definition: Graph.h:21