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