| 176 | */ |
| 177 | template <typename IndexVector> |
| 178 | void treePostorder(typename IndexVector::Scalar n, IndexVector& parent, IndexVector& post) |
| 179 | { |
| 180 | typedef typename IndexVector::Scalar StorageIndex; |
| 181 | IndexVector first_kid, next_kid; // Linked list of children |
| 182 | StorageIndex postnum; |
| 183 | // Allocate storage for working arrays and results |
| 184 | first_kid.resize(n+1); |
| 185 | next_kid.setZero(n+1); |
| 186 | post.setZero(n+1); |
| 187 | |
| 188 | // Set up structure describing children |
| 189 | first_kid.setConstant(-1); |
| 190 | for (StorageIndex v = n-1; v >= 0; v--) |
| 191 | { |
| 192 | StorageIndex dad = parent(v); |
| 193 | next_kid(v) = first_kid(dad); |
| 194 | first_kid(dad) = v; |
| 195 | } |
| 196 | |
| 197 | // Depth-first search from dummy root vertex #n |
| 198 | postnum = 0; |
| 199 | internal::nr_etdfs(n, parent, first_kid, next_kid, post, postnum); |
| 200 | } |
| 201 | |
| 202 | } // end namespace internal |
| 203 |
no test coverage detected