This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/CLPBN/clpbn/bp/BayesNet.h

89 lines
1.8 KiB
C
Raw Normal View History

2011-12-12 15:29:51 +00:00
#ifndef HORUS_BAYESNET_H
#define HORUS_BAYESNET_H
#include <vector>
#include <queue>
#include <list>
#include <map>
2012-04-05 23:00:48 +01:00
#include "Var.h"
2012-03-22 11:33:24 +00:00
#include "Horus.h"
using namespace std;
2012-04-05 23:00:48 +01:00
class Var;
2012-04-05 18:38:56 +01:00
2012-04-05 23:00:48 +01:00
class DAGraphNode : public Var
{
2012-04-05 18:38:56 +01:00
public:
2012-04-05 23:00:48 +01:00
DAGraphNode (Var* v) : Var (v) , visited_(false),
2012-04-05 18:38:56 +01:00
markedOnTop_(false), markedOnBottom_(false) { }
const vector<DAGraphNode*>& childs (void) const { return childs_; }
vector<DAGraphNode*>& childs (void) { return childs_; }
const vector<DAGraphNode*>& parents (void) const { return parents_; }
vector<DAGraphNode*>& parents (void) { return parents_; }
void addParent (DAGraphNode* p) { parents_.push_back (p); }
void addChild (DAGraphNode* c) { childs_.push_back (c); }
bool isVisited (void) const { return visited_; }
void setAsVisited (void) { visited_ = true; }
bool isMarkedOnTop (void) const { return markedOnTop_; }
void markOnTop (void) { markedOnTop_ = true; }
bool isMarkedOnBottom (void) const { return markedOnBottom_; }
void markOnBottom (void) { markedOnBottom_ = true; }
void clear (void) { visited_ = markedOnTop_ = markedOnBottom_ = false; }
private:
bool visited_;
bool markedOnTop_;
bool markedOnBottom_;
vector<DAGraphNode*> childs_;
vector<DAGraphNode*> parents_;
};
2012-04-05 18:38:56 +01:00
class DAGraph
{
2012-04-05 18:38:56 +01:00
public:
DAGraph (void) { }
void addNode (DAGraphNode* n);
void addEdge (VarId vid1, VarId vid2);
2012-04-05 18:38:56 +01:00
const DAGraphNode* getNode (VarId vid) const;
DAGraphNode* getNode (VarId vid);
bool empty (void) const { return nodes_.empty(); }
void setIndexes (void);
void clear (void);
void exportToGraphViz (const char*);
private:
vector<DAGraphNode*> nodes_;
unordered_map<VarId, DAGraphNode*> varMap_;
};
2012-03-31 23:27:37 +01:00
2011-12-12 15:29:51 +00:00
#endif // HORUS_BAYESNET_H