Augment a `flow` amount along the path defined by `prev`.*/
| 223 | |
| 224 | /* Augment a `flow` amount along the path defined by `prev`.*/ |
| 225 | static void augment_flow(const struct graph *graph, |
| 226 | const struct node source, |
| 227 | const struct node target, |
| 228 | const struct arc *prev, |
| 229 | s64 *excess, |
| 230 | s64 *capacity, |
| 231 | s64 flow) |
| 232 | { |
| 233 | const size_t max_num_nodes = graph_max_num_nodes(graph); |
| 234 | const size_t max_num_arcs = graph_max_num_arcs(graph); |
| 235 | assert(max_num_nodes == tal_count(prev)); |
| 236 | assert(max_num_arcs == tal_count(capacity)); |
| 237 | |
| 238 | struct node cur = target; |
| 239 | /* count the number of arcs in the path */ |
| 240 | int path_length = 0; |
| 241 | |
| 242 | while (cur.idx != source.idx) { |
| 243 | assert(cur.idx < max_num_nodes); |
| 244 | const struct arc arc = prev[cur.idx]; |
| 245 | |
| 246 | sendflow(graph, arc, flow, capacity, excess); |
| 247 | |
| 248 | /* we are traversing in the opposite direction to the flow, |
| 249 | * hence the next node is at the tail of the arc. */ |
| 250 | cur = arc_tail(graph, arc); |
| 251 | |
| 252 | /* We may never have a path exceeds the number of nodes, it this |
| 253 | * happens it means we have an infinite loop. */ |
| 254 | path_length++; |
| 255 | if (path_length >= max_num_nodes) |
| 256 | break; |
| 257 | } |
| 258 | assert(path_length < max_num_nodes); |
| 259 | } |
| 260 | |
| 261 | bool simple_feasibleflow(const tal_t *ctx, |
| 262 | const struct graph *graph, |
no test coverage detected