Add cycle detect adding edges

This commit is contained in:
2023-06-29 23:53:33 +02:00
parent d59bf03a51
commit 31c22898de
5 changed files with 87 additions and 18 deletions

11
main.cc
View File

@@ -26,6 +26,13 @@ int main()
}
cout << "Hello, Bayesian Networks!" << endl;
torch::Tensor tensor = torch::eye(3);
cout << "Now I'll add a cycle" << endl;
try {
network.addEdge("petallength", className);
}
catch (invalid_argument& e) {
cout << e.what() << endl;
}
cout << tensor << std::endl;
cout << "Nodes:" << endl;
for (auto [name, item] : network.getNodes()) {
@@ -39,5 +46,9 @@ int main()
cout << " " << child->getName() << endl;
}
}
cout << "Root: " << network.getRoot()->getName() << endl;
network.setRoot(className);
cout << "Now Root should be class: " << network.getRoot()->getName() << endl;
return 0;
}