| 307 | } |
| 308 | |
| 309 | s64 node_balance(const struct graph *graph, |
| 310 | const struct node node, |
| 311 | const s64 *capacity) |
| 312 | { |
| 313 | s64 balance = 0; |
| 314 | |
| 315 | for (struct arc arc = node_adjacency_begin(graph, node); |
| 316 | !node_adjacency_end(arc); arc = node_adjacency_next(graph, arc)) { |
| 317 | struct arc dual = arc_dual(graph, arc); |
| 318 | |
| 319 | if (arc_is_dual(graph, arc)) |
| 320 | balance += capacity[arc.idx]; |
| 321 | else |
| 322 | balance -= capacity[dual.idx]; |
| 323 | } |
| 324 | return balance; |
| 325 | } |
| 326 | |
| 327 | /* Helper. |
| 328 | * Compute the reduced cost of an arc. */ |