The following code segment shows what I'd like to do. I'm a procedural programmer trying to learn the Mathematica functional style. Any help on this would be appreciated.
B = {{1, 3}, {1, 5}, {4, 2}, {5, 2}, {5, 5}}
u = SparseArray[{{1, 2} -> 5, {1, 3} -> 9, {1, 4} -> 6,
{1, 5} -> Infinity, {3, 2} -> 2, {3, 4} -> 4,
{4, 2} -> 9, {5, 2} -> Infinity, {5, 3} -> Infinity,
{5, 4} -> Infinity, {5, 5} -> Infinity}];
r = {3, 0, -2, 10, 19}
(* Want to convert this python-looking code to functional Mathematica code
for {i, j} in B :
r[i] = r[i] - u[[i, j]]
r[j] = r[j] + u[[i, j]]
*)
-=
and+=
operators to shorten the code $\endgroup$