Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
comparison docs/algorithm-ford-fulkerson.pseudocode @ 116:9bfd87544902
Use arrows from Supplemental Arrows-A Unicode block where appropriate: better readability
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 06 May 2026 10:05:57 +0200 |
| parents | 6cebd3e7bc97 |
| children |
comparison
equal
deleted
inserted
replaced
| 115:e1663ac707b0 | 116:9bfd87544902 |
|---|---|
| 1 // -*- coding: utf-8; indent-tabs-mode: nil -*- | 1 // -*- coding: utf-8; indent-tabs-mode: nil -*- |
| 2 \ALGORITHM{Ford–Fulkerson} \WITH | 2 \ALGORITHM{Ford–Fulkerson} \WITH |
| 3 \INPUTS{Given a network \expr{G = (V, E)} with flow capacity \expr{c}, a source node \expr{s}, and a sink node \expr{t}} | 3 \INPUTS{Given a network \expr{G = (V, E)} with flow capacity \expr{c}, a source node \expr{s}, and a sink node \expr{t}} |
| 4 \OUTPUT{Compute a flow \expr{f} from \expr{s} to \expr{t} of maximum value} | 4 \OUTPUT{Compute a flow \expr{f} from \expr{s} to \expr{t} of maximum value} |
| 5 \IS | 5 \IS |
| 6 \TEXT{1. \expr{f(u, v) <- 0} for all edges \expr{(u, v)} | 6 \TEXT{1. \expr{f(u, v) \gets 0} for all edges \expr{(u, v)} |
| 7 | 7 |
| 8 2. While there is a path \expr{p} from \expr{s} to \expr{t} in \expr{G_f}, | 8 2. While there is a path \expr{p} from \expr{s} to \expr{t} in \expr{G_f}, |
| 9 such that \expr{c_f(u, v) > 0} for all edges \expr{(u, v) ∈ p}: | 9 such that \expr{c_f(u, v) > 0} for all edges \expr{(u, v) ∈ p}: |
| 10 | 10 |
| 11 1. Find \expr{c_f(p) = min{c_f(u, v): (u, v) ∈ p\}} | 11 1. Find \expr{c_f(p) = min{c_f(u, v): (u, v) ∈ p\}} |
| 12 | 12 |
| 13 2. For each edge \expr{(u, v) ∈ p} | 13 2. For each edge \expr{(u, v) ∈ p} |
| 14 | 14 |
| 15 1. \expr{f(u, v) <- f(u, v) + c_f(p)} \rem Send flow along the path | 15 1. \expr{f(u, v) \gets f(u, v) + c_f(p)} \rem Send flow along the path |
| 16 | 16 |
| 17 2. \expr{f(v, u) <- f(v, u) - c_f(p)} \rem The flow might be "returned" later | 17 2. \expr{f(v, u) \gets f(v, u) - c_f(p)} \rem The flow might be "returned" later |
| 18 } | 18 } |
| 19 \END ALGORITHM {Ford–Fulkerson} | 19 \END ALGORITHM {Ford–Fulkerson} |
