Add copy constructor to network

This commit is contained in:
2023-07-02 16:15:14 +02:00
parent 59e5794e5d
commit d6d683bb5c
3 changed files with 80 additions and 0 deletions

View File

@@ -2,6 +2,12 @@
namespace bayesnet {
Network::Network() : laplaceSmoothing(1), root(nullptr), features(vector<string>()), className("") {}
Network::Network(int smoothing) : laplaceSmoothing(smoothing), root(nullptr), features(vector<string>()), className("") {}
Network::Network(Network& other) : laplaceSmoothing(other.laplaceSmoothing), root(other.root), features(other.features), className(other.className)
{
for (auto& pair : other.nodes) {
nodes[pair.first] = new Node(*pair.second);
}
}
Network::~Network()
{
for (auto& pair : nodes) {

View File

@@ -19,6 +19,7 @@ namespace bayesnet {
public:
Network();
Network(int);
Network(Network&);
~Network();
void addNode(string, int);
void addEdge(const string, const string);