reversed order of nodes in dot

release/4.3a0
Frank Dellaert 2021-12-19 10:20:05 -05:00
parent d85a1e68e4
commit 46080d7d5a
2 changed files with 9 additions and 3 deletions

View File

@ -163,7 +163,13 @@ TEST(DiscreteBayesNet, Dot) {
fragment.add((Either | Tuberculosis, LungCancer) = "F T T T"); fragment.add((Either | Tuberculosis, LungCancer) = "F T T T");
string actual = fragment.dot(); string actual = fragment.dot();
EXPECT(actual == "digraph G{\n3->5\n6->5\n4->6\n0->3\n}"); EXPECT(actual ==
"digraph G{\n"
"0->3\n"
"4->6\n"
"3->5\n"
"6->5\n"
"}");
} }
/* ************************************************************************* */ /* ************************************************************************* */

View File

@ -39,8 +39,8 @@ void BayesNet<CONDITIONAL>::dot(std::ostream& os,
const KeyFormatter& keyFormatter) const { const KeyFormatter& keyFormatter) const {
os << "digraph G{\n"; os << "digraph G{\n";
for (auto conditional : boost::adaptors::reverse(*this)) { for (auto conditional : *this) {
typename CONDITIONAL::Frontals frontals = conditional->frontals(); auto frontals = conditional->frontals();
const Key me = frontals.front(); const Key me = frontals.front();
auto parents = conditional->parents(); auto parents = conditional->parents();
for (const Key& p : parents) for (const Key& p : parents)