Begin Network build

This commit is contained in:
2023-06-29 22:00:41 +02:00
parent 00ed1e0be1
commit 8e9c3483aa
18 changed files with 874 additions and 0 deletions

41
Node.cc Normal file
View File

@@ -0,0 +1,41 @@
#include "Node.h"
namespace bayesnet {
int Node::next_id = 0;
Node::Node(const std::string& name, int numStates)
: id(next_id++), name(name), numStates(numStates), cpt(torch::Tensor()), parents(vector<Node*>()), children(vector<Node*>())
{
}
string Node::getName() const
{
return name;
}
void Node::addParent(Node* parent)
{
parents.push_back(parent);
}
void Node::addChild(Node* child)
{
children.push_back(child);
}
vector<Node*>& Node::getParents()
{
return parents;
}
vector<Node*>& Node::getChildren()
{
return children;
}
int Node::getNumStates() const
{
return numStates;
}
string Node::getCPDKey(const Node* child) const
{
return name + "-" + child->getName();
}
}