Direct Graphical Models  v.1.7.0
IGraphPairwise.h
1 // Graph interface class;
2 // Written by Sergey Kosov in 2015 for Project X
3 #pragma once
4 
5 #include "Graph.h"
6 #include <optional>
7 
8 namespace DirectGraphicalModels {
9  // ================================ Graph Interface Class ================================
15  class IGraphPairwise : public CGraph
16  {
17  public:
22  DllExport IGraphPairwise(byte nStates) : CGraph(nStates) {}
23  DllExport virtual ~IGraphPairwise(void) = default;
24 
33  DllExport void marginalize(const vec_size_t &nodes);
40  DllExport void addEdge(size_t srcNode, size_t dstNode, const Mat &pot = EmptyMat);
48  DllExport virtual void addEdge(size_t srcNode, size_t dstNode, byte group, const Mat &pot) = 0;
55  DllExport virtual void setEdge(size_t srcNode, size_t dstNode, const Mat &pot) = 0;
63  DllExport virtual void setEdges(std::optional<byte> group, const Mat& pot) = 0;
70  DllExport virtual void getEdge(size_t srcNode, size_t dstNode, Mat &pot) const = 0;
77  DllExport virtual void setEdgeGroup(size_t srcNode, size_t dstNode, byte group) = 0;
84  DllExport virtual byte getEdgeGroup(size_t srcNode, size_t dstNode) const = 0;
90  DllExport virtual void removeEdge(size_t srcNode, size_t dstNode) = 0;
98  DllExport virtual bool isEdgeExists(size_t srcNode, size_t dstNode) const = 0;
107  DllExport virtual bool isEdgeArc(size_t srcNode, size_t dstNode) const;
119  DllExport void addArc(size_t Node1, size_t Node2, const Mat &pot = EmptyMat);
132  DllExport virtual void addArc(size_t Node1, size_t Node2, byte group, const Mat &pot);
144  DllExport virtual void setArc(size_t Node1, size_t Node2, const Mat &pot);
151  DllExport virtual void setArcGroup(size_t Node1, size_t Node2, byte group);
157  DllExport virtual void removeArc(size_t Node1, size_t Node2);
165  DllExport virtual bool isArcExists(size_t Node1, size_t Node2) const;
166  };
167 }
virtual void setArcGroup(size_t Node1, size_t Node2, byte group)
Assigns an undirected edge (arc) (Node1) – (Node2) to the group group.
virtual void setEdges(std::optional< byte > group, const Mat &pot)=0
Sets the potential pot to all edges belonging to group group.
void addArc(size_t Node1, size_t Node2, const Mat &pot=EmptyMat)
Adds an additional udirected edge (arc) with specified potentional.
virtual bool isEdgeExists(size_t srcNode, size_t dstNode) const =0
Checks whether the edge exists.
IGraphPairwise(byte nStates)
Constructor.
virtual void setEdgeGroup(size_t srcNode, size_t dstNode, byte group)=0
Assigns a directed edge (srcNode) –> (dstNode) to the group group.
void marginalize(const vec_size_t &nodes)
Marginalizes a set of nodes.
virtual void removeArc(size_t Node1, size_t Node2)
Removes the specified arc.
virtual bool isArcExists(size_t Node1, size_t Node2) const
Checks whether the arc exists.
virtual ~IGraphPairwise(void)=default
Interface class for graphical models.
Definition: Graph.h:14
virtual byte getEdgeGroup(size_t srcNode, size_t dstNode) const =0
Returns the group of the edge.
void addEdge(size_t srcNode, size_t dstNode, const Mat &pot=EmptyMat)
Adds an additional directed edge with specified potentional.
virtual void getEdge(size_t srcNode, size_t dstNode, Mat &pot) const =0
Returns the edge potential.
virtual void setEdge(size_t srcNode, size_t dstNode, const Mat &pot)=0
Sets or changes the potentional of directed edge.
Interface class for graphical models.
virtual void setArc(size_t Node1, size_t Node2, const Mat &pot)
Sets or changes the potentional of udirected edge (arc)
virtual void removeEdge(size_t srcNode, size_t dstNode)=0
Removes the specified edge.
virtual bool isEdgeArc(size_t srcNode, size_t dstNode) const
Checks whether the edge is a part of an arc.