| 160 | } |
| 161 | |
| 162 | std::vector<NodeID> post_order(const NodeTree &tree) |
| 163 | { |
| 164 | std::stack<NodeID> stk_1; |
| 165 | std::vector<NodeID> result; |
| 166 | |
| 167 | result.reserve(tree.nodeCount()); |
| 168 | |
| 169 | auto root = tree.getRoot(); |
| 170 | |
| 171 | stk_1.push(root); |
| 172 | |
| 173 | while (!stk_1.empty()) |
| 174 | { |
| 175 | auto nid = stk_1.top(); |
| 176 | stk_1.pop(); |
| 177 | |
| 178 | result.push_back(nid); |
| 179 | |
| 180 | for (auto i = 0; i < tree.childrenCount(nid); ++i) |
| 181 | { |
| 182 | auto child = tree.getChild(nid, i); |
| 183 | stk_1.push(child); |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | std::reverse(result.begin(), result.end()); |
| 188 | |
| 189 | return result; |
| 190 | } |
| 191 | |
| 192 | std::vector<int> calc_subtree_sizes(const tree::NodeTree &nt) |
| 193 | { |
no test coverage detected