| 130 | */ |
| 131 | template <typename IndexVector> |
| 132 | void nr_etdfs (typename IndexVector::Scalar n, IndexVector& parent, IndexVector& first_kid, IndexVector& next_kid, IndexVector& post, typename IndexVector::Scalar postnum) |
| 133 | { |
| 134 | typedef typename IndexVector::Scalar StorageIndex; |
| 135 | StorageIndex current = n, first, next; |
| 136 | while (postnum != n) |
| 137 | { |
| 138 | // No kid for the current node |
| 139 | first = first_kid(current); |
| 140 | |
| 141 | // no kid for the current node |
| 142 | if (first == -1) |
| 143 | { |
| 144 | // Numbering this node because it has no kid |
| 145 | post(current) = postnum++; |
| 146 | |
| 147 | // looking for the next kid |
| 148 | next = next_kid(current); |
| 149 | while (next == -1) |
| 150 | { |
| 151 | // No more kids : back to the parent node |
| 152 | current = parent(current); |
| 153 | // numbering the parent node |
| 154 | post(current) = postnum++; |
| 155 | |
| 156 | // Get the next kid |
| 157 | next = next_kid(current); |
| 158 | } |
| 159 | // stopping criterion |
| 160 | if (postnum == n+1) return; |
| 161 | |
| 162 | // Updating current node |
| 163 | current = next; |
| 164 | } |
| 165 | else |
| 166 | { |
| 167 | current = first; |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | |
| 173 | /** |