diff --git a/cpp/BayesTree-inl.h b/cpp/BayesTree-inl.h index 94980879f..a41965b20 100644 --- a/cpp/BayesTree-inl.h +++ b/cpp/BayesTree-inl.h @@ -95,6 +95,7 @@ namespace gtsam { /* ************************************************************************* */ template void BayesTree::saveGraph(const std::string &s) const { + if (!root_.get()) throw invalid_argument("the root of bayes tree has not been initialized!"); ofstream of(s.c_str()); of<< "digraph G{\n"; saveGraph(of, root_);