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

85 lines
1.8 KiB
C
Raw Normal View History

2013-02-07 17:50:02 +00:00
#ifndef YAP_PACKAGES_CLPBN_HORUS_BAYESBALLGRAPH_H_
#define YAP_PACKAGES_CLPBN_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"
2013-02-07 23:53:13 +00:00
namespace horus {
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) { }
2013-02-07 13:37:15 +00:00
const std::vector<BBNode*>& childs (void) const { return childs_; }
2012-05-23 14:56:01 +01:00
2013-02-07 13:37:15 +00:00
std::vector<BBNode*>& childs (void) { return childs_; }
2012-05-23 14:56:01 +01:00
2013-02-07 13:37:15 +00:00
const std::vector<BBNode*>& parents (void) const { return parents_; }
2012-05-23 14:56:01 +01:00
2013-02-07 13:37:15 +00:00
std::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_;
2013-02-07 13:37:15 +00:00
std::vector<BBNode*> childs_;
std::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
bool empty (void) const { return nodes_.empty(); }
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
void setIndexes (void);
void clear (void);
void exportToGraphViz (const char*);
private:
2013-02-07 13:37:15 +00:00
std::vector<BBNode*> nodes_;
2012-05-23 14:56:01 +01:00
2013-02-07 13:37:15 +00:00
std::unordered_map<VarId, BBNode*> varMap_;
2012-05-23 14:56:01 +01:00
};
2013-02-07 23:53:13 +00:00
} // namespace horus
2013-02-08 00:20:01 +00:00
#endif // YAP_PACKAGES_CLPBN_HORUS_BAYESBALLGRAPH_H_
2012-05-23 14:56:01 +01:00