MCPcopy Create free account
hub / github.com/ElementsProject/lightning / augment_flow

Function augment_flow

plugins/renepay/mcf.c:908–936  ·  view source on GitHub ↗

Augment a `flow` amount along the path defined by `prev`.*/

Source from the content-addressed store, hash-verified

906
907/* Augment a `flow` amount along the path defined by `prev`.*/
908static 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

Callers 2

find_feasible_flowFunction · 0.70
optimize_mcfFunction · 0.70

Calls 2

arc_dualFunction · 0.70
arc_tailFunction · 0.70

Tested by

no test coverage detected