BayesNet-inst.h
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3 * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4 * Atlanta, Georgia 30332-0415
5 * All Rights Reserved
6 * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8 * See LICENSE for the license information
9 
10 * -------------------------------------------------------------------------- */
11 
19 #pragma once
20 
23 
24 #include <boost/range/adaptor/reversed.hpp>
25 #include <fstream>
26 
27 namespace gtsam {
28 
29 /* ************************************************************************* */
30 template <class CONDITIONAL>
32  const std::string& s, const KeyFormatter& formatter) const {
33  Base::print(s, formatter);
34 }
35 
36 /* ************************************************************************* */
37 template <class CONDITIONAL>
38 void BayesNet<CONDITIONAL>::saveGraph(const std::string& s,
39  const KeyFormatter& keyFormatter) const {
40  std::ofstream of(s.c_str());
41  of << "digraph G{\n";
42 
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();
47  for (Key p : parents)
48  of << keyFormatter(p) << "->" << keyFormatter(me) << std::endl;
49  }
50 
51  of << "}";
52  of.close();
53 }
54 
55 } // namespace gtsam
void print(const Matrix &A, const string &s, ostream &stream)
Definition: Matrix.cpp:155
Bayes network.
const KeyFormatter & formatter
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
RealScalar s
traits
Definition: chartTesting.h:28
void saveGraph(const std::string &s, const KeyFormatter &keyFormatter=DefaultKeyFormatter) const
Definition: BayesNet-inst.h:38
void reverse(const MatrixType &m)
float * p
std::uint64_t Key
Integer nonlinear key type.
Definition: types.h:61
void print(const std::string &s="BayesNet", const KeyFormatter &formatter=DefaultKeyFormatter) const override
Definition: BayesNet-inst.h:31


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:41