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/horus/BayesBallGraph.h

83 lines
1.7 KiB
C
Raw Normal View History

2012-06-19 14:32:12 +01:00
#ifndef HORUS_BAYESBALLGRAPH_H
#define HORUS_BAYESBALLGRAPH_H
2012-05-23 14:56:01 +01:00
#include <vector>
2012-12-27 12:54:58 +00:00
#include <unordered_map>
2012-05-23 14:56:01 +01:00
#include "Var.h"
#include "Horus.h"
using namespace std;
2012-06-19 14:32:12 +01:00
class BBNode : public Var
2012-05-23 14:56:01 +01:00
{
public:
2012-12-27 12:54:58 +00:00
BBNode (Var* v) : Var (v), visited_(false),
2012-05-23 14:56:01 +01:00
markedOnTop_(false), markedOnBottom_(false) { }
2012-06-19 14:32:12 +01:00
const vector<BBNode*>& childs (void) const { return childs_; }
2012-05-23 14:56:01 +01:00
2012-06-19 14:32:12 +01:00
vector<BBNode*>& childs (void) { return childs_; }
2012-05-23 14:56:01 +01:00
2012-06-19 14:32:12 +01:00
const vector<BBNode*>& parents (void) const { return parents_; }
2012-05-23 14:56:01 +01:00
2012-06-19 14:32:12 +01:00
vector<BBNode*>& parents (void) { return parents_; }
2012-05-23 14:56:01 +01:00
2012-06-19 14:32:12 +01:00
void addParent (BBNode* p) { parents_.push_back (p); }
2012-05-23 14:56:01 +01:00
2012-06-19 14:32:12 +01:00
void addChild (BBNode* c) { childs_.push_back (c); }
2012-05-23 14:56:01 +01:00
bool isVisited (void) const { return visited_; }
2012-12-20 23:19:10 +00:00
2012-05-23 14:56:01 +01:00
void setAsVisited (void) { visited_ = true; }
bool isMarkedOnTop (void) const { return markedOnTop_; }
2012-12-20 23:19:10 +00:00
2012-05-23 14:56:01 +01:00
void markOnTop (void) { markedOnTop_ = true; }
bool isMarkedOnBottom (void) const { return markedOnBottom_; }
2012-12-20 23:19:10 +00:00
2012-05-23 14:56:01 +01:00
void markOnBottom (void) { markedOnBottom_ = true; }
void clear (void) { visited_ = markedOnTop_ = markedOnBottom_ = false; }
private:
bool visited_;
bool markedOnTop_;
bool markedOnBottom_;
2012-06-19 14:32:12 +01:00
vector<BBNode*> childs_;
vector<BBNode*> parents_;
2012-05-23 14:56:01 +01:00
};
2012-06-19 14:32:12 +01:00
class BayesBallGraph
2012-05-23 14:56:01 +01:00
{
public:
2012-06-19 14:32:12 +01:00
BayesBallGraph (void) { }
2012-05-23 14:56:01 +01:00
2012-06-19 14:32:12 +01:00
void addNode (BBNode* n);
2012-05-23 14:56:01 +01:00
void addEdge (VarId vid1, VarId vid2);
2012-06-19 14:32:12 +01:00
const BBNode* getNode (VarId vid) const;
2012-12-17 18:39:42 +00:00
2012-06-19 14:32:12 +01:00
BBNode* getNode (VarId vid);
2012-05-23 14:56:01 +01:00
bool empty (void) const { return nodes_.empty(); }
void setIndexes (void);
void clear (void);
void exportToGraphViz (const char*);
private:
2012-06-19 14:32:12 +01:00
vector<BBNode*> nodes_;
2012-05-23 14:56:01 +01:00
2012-06-19 14:32:12 +01:00
unordered_map<VarId, BBNode*> varMap_;
2012-05-23 14:56:01 +01:00
};
2012-06-19 14:32:12 +01:00
#endif // HORUS_BAYESBALLGRAPH_H
2012-05-23 14:56:01 +01:00