21#include <gtsam/inference/FactorGraph-inst.h>
24#include <boost/range/adaptor/reversed.hpp>
30template <
class CONDITIONAL>
32 const std::string& s,
const KeyFormatter& formatter)
const {
37template <
class CONDITIONAL>
40 std::ofstream of(s.c_str());
43 for (
auto conditional : boost::adaptors::reverse(*
this)) {
44 typename CONDITIONAL::Frontals frontals = conditional->frontals();
45 Key me = frontals.front();
46 typename CONDITIONAL::Parents parents = conditional->parents();
48 of << keyFormatter(p) <<
"->" << keyFormatter(me) << std::endl;
Global functions in a separate testing namespace.
Definition: chartTesting.h:28
void print(const Matrix &A, const string &s, ostream &stream)
print without optional string, must specify cout yourself
Definition: Matrix.cpp:155
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:69
std::function< std::string(Key)> KeyFormatter
Typedef for a function to format a key, i.e. to convert it to a string.
Definition: Key.h:35
A BayesNet is a tree of conditionals, stored in elimination order.
Definition: BayesNet.h:34
void print(const std::string &s="BayesNet", const KeyFormatter &formatter=DefaultKeyFormatter) const override
print out graph
Definition: BayesNet-inst.h:31