26 using namespace gtsam;
50 forest.
roots_.push_back(std::make_shared<TestNode>(0));
51 forest.
roots_.push_back(std::make_shared<TestNode>(1));
52 forest.
roots_[0]->children.push_back(std::make_shared<TestNode>(2));
53 forest.
roots_[0]->children.push_back(std::make_shared<TestNode>(3));
54 forest.
roots_[0]->children[1]->children.push_back(std::make_shared<TestNode>(4));
67 visited.push_back(node->data);
69 const int expectedParentIndex =
70 node->data == 0 ? -1 :
71 node->data == 1 ? -1 :
75 node->data == 10 ? 0 :
76 (parentsMatched =
false, -1);
78 parentsMatched =
false;
88 visited.push_back(node->data);
103 TEST(treeTraversal, DepthFirst)
109 const std::list<int> preOrderExpected{0, 2, 3, 4, 1};
110 const std::list<int> postOrderExpected{2, 4, 3, 0, 1};
132 const std::list<int> preOrder1Expected{0, 2, 3, 4, 1};
133 std::list<int> preOrder1Actual =
getPreorder(testForest1);
134 std::list<int> preOrder2Actual =
getPreorder(testForest2);
139 testForest2.
roots_[0]->children[1]->data = 10;
140 const std::list<int> preOrderModifiedExpected{0, 2, 10, 4, 1};
143 std::list<int> preOrder1ModActual =
getPreorder(testForest1);
144 std::list<int> preOrder2ModActual =
getPreorder(testForest2);