* Add this path as a new child to the given base path, thus making this path * a "fork" of the base path. * @param base Path to fork from. * @param cap Maximum capacity of the new leg. * @param free_cap Remaining free capacity of the new leg. * @param dist Distance of the new leg. */
| 197 | * @param dist Distance of the new leg. |
| 198 | */ |
| 199 | void Path::Fork(Path *base, uint cap, int free_cap, uint dist) |
| 200 | { |
| 201 | this->capacity = std::min(base->capacity, cap); |
| 202 | this->free_capacity = std::min(base->free_capacity, free_cap); |
| 203 | this->distance = base->distance + dist; |
| 204 | assert(this->distance > 0); |
| 205 | if (this->parent != base) { |
| 206 | this->Detach(); |
| 207 | this->parent = base; |
| 208 | this->parent->num_children++; |
| 209 | } |
| 210 | this->origin = base->origin; |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * Push some flow along a path and register the path in the nodes it passes if |