Augment a `flow` amount along the path defined by `prev`.*/
| 906 | |
| 907 | /* Augment a `flow` amount along the path defined by `prev`.*/ |
| 908 | static void augment_flow( |
| 909 | const struct linear_network *linear_network, |
| 910 | struct residual_network *residual_network, |
| 911 | const u32 source, |
| 912 | const u32 target, |
| 913 | const struct arc *prev, |
| 914 | s64 flow) |
| 915 | { |
| 916 | u32 cur = target; |
| 917 | |
| 918 | while(cur!=source) |
| 919 | { |
| 920 | assert(cur < tal_count(prev)); |
| 921 | const struct arc arc = prev[cur]; |
| 922 | const struct arc dual = arc_dual(arc); |
| 923 | |
| 924 | assert(arc.idx < tal_count(residual_network->cap)); |
| 925 | assert(dual.idx < tal_count(residual_network->cap)); |
| 926 | |
| 927 | residual_network->cap[arc.idx] -= flow; |
| 928 | residual_network->cap[dual.idx] += flow; |
| 929 | |
| 930 | assert(residual_network->cap[arc.idx] >=0 ); |
| 931 | |
| 932 | // we are traversing in the opposite direction to the flow, |
| 933 | // hence the next node is at the tail of the arc. |
| 934 | cur = arc_tail(linear_network,arc); |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | |
| 939 | // TODO(eduardo): unit test this |
no test coverage detected