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