| 166 | */ |
| 167 | template <typename IndexVector> |
| 168 | void treePostorder(typename IndexVector::Scalar n, IndexVector& parent, IndexVector& post) { |
| 169 | typedef typename IndexVector::Scalar StorageIndex; |
| 170 | IndexVector first_kid, next_kid; // Linked list of children |
| 171 | StorageIndex postnum; |
| 172 | // Allocate storage for working arrays and results |
| 173 | first_kid.resize(n + 1); |
| 174 | next_kid.setZero(n + 1); |
| 175 | post.setZero(n + 1); |
| 176 | |
| 177 | // Set up structure describing children |
| 178 | first_kid.setConstant(-1); |
| 179 | for (StorageIndex v = n - 1; v >= 0; v--) { |
| 180 | StorageIndex dad = parent(v); |
| 181 | next_kid(v) = first_kid(dad); |
| 182 | first_kid(dad) = v; |
| 183 | } |
| 184 | |
| 185 | // Depth-first search from dummy root vertex #n |
| 186 | postnum = 0; |
| 187 | internal::nr_etdfs(n, parent, first_kid, next_kid, post, postnum); |
| 188 | } |
| 189 | |
| 190 | } // end namespace internal |
| 191 |
no test coverage detected