Ford–Fulkerson algorithm
admin
2024-02-29 19:06:33
0

The Ford–Fulkerson method or Ford–Fulkerson algorithm (FFA) is a greedy algorithm that computes the maximum flow in a flow network. It is sometimes called a “method” instead of an “algorithm” as the approach to finding augmenting paths in a residual graph is not fully specified[1] or it is specified in several implementations with different running times.[2] It was published in 1956 by L. R. Ford Jr. and D. R. Fulkerson.[3] The name “Ford–Fulkerson” is often also used for the Edmonds–Karp algorithm, which is a fully defined implementation of the Ford–Fulkerson method.

The idea behind the algorithm is as follows: as long as there is a path from the source (start node) to the sink (end node), with available capacity on all edges in the path, we send flow along one of the paths. Then we find another path, and so on. A path with available capacity is called an augmenting path.

Contents

  • 1 Algorithm
  • 2 Complexity
  • 3 Integral example
  • 4 Non-terminating example
  • 5 Python implementation of Edmonds–Karp algorithm
  • 6 See also

1 Algorithm

Let {\displaystyle G(V,E)}G(V,E) be a graph, and for each edge from u to v, let {\displaystyle c(u,v)}c(u,v) be the capacity and {\displaystyle f(u,v)}f(u,v) be the flow. We want to find the maximum flow from the source s to the sink t. After every step in the algorithm the following is maintained:

Capacity constraints {\displaystyle \forall (u,v)\in E:\ f(u,v)\leq c(u,v)}{\displaystyle \forall (u,v)\in E:\ f(u,v)\leq c(u,v)} The flow along an edge cannot exceed its capacity.
Skew symmetry {\displaystyle \forall (u,v)\in E:\ f(u,v)=-f(v,u)}{\displaystyle \forall (u,v)\in E:\ f(u,v)=-f(v,u)} The net flow from u to v must be the opposite of the net flow from v to u (see example).
Flow conservation {\displaystyle \forall u\in V:u\neq s{\text{ and }}u\neq t\Rightarrow \sum {w\in V}f(u,w)=0}\forall u\in V:u\neq s{\text{ and }}u\neq t\Rightarrow \sum {w\in V}f(u,w)=0 The net flow to a node is zero, except for the source, which “produces” flow, and the sink, which “consumes” flow.
Value(f) {\displaystyle \sum {(s,u)\in E}f(s,u)=\sum {(v,t)\in E}f(v,t)}\sum {(s,u)\in E}f(s,u)=\sum {(v,t)\in E}f(v,t) The flow leaving from s must be equal to the flow arriving at t.
This means that the flow through the network is a legal flow after each round in the algorithm. We define the residual network {\displaystyle G
{f}(V,E
{f})}G
{f}(V,E
{f}) to be the network with capacity {\displaystyle c
{f}(u,v)=c(u,v)-f(u,v)}c
{f}(u,v)=c(u,v)-f(u,v) and no flow. Notice that it can happen that a flow from v to u is allowed in the residual network, though disallowed in the original network: if {\displaystyle f(u,v)>0}f(u,v)>0 and {\displaystyle c(v,u)=0}c(v,u)=0 then {\displaystyle c_{f}(v,u)=c(v,u)-f(v,u)=f(u,v)>0}c_{f}(v,u)=c(v,u)-f(v,u)=f(u,v)>0.

Algorithm Ford–Fulkerson
Inputs Given a Network {\displaystyle G=(V,E)}G=(V,E) with flow capacity c, a source node s, and a sink node t
Output Compute a flow f from s to t of maximum value
{\displaystyle f(u,v)\leftarrow 0}f(u,v)\leftarrow 0 for all edges {\displaystyle (u,v)}(u,v)
While there is a path p from s to t in {\displaystyle G_{f}}G_{f}, such that {\displaystyle c_{f}(u,v)>0}c_{f}(u,v)>0 for all edges {\displaystyle (u,v)\in p}(u,v)\in p:
Find {\displaystyle c_{f}§=\min{c_{f}(u,v):(u,v)\in p}}c_{f}§=\min{c_{f}(u,v):(u,v)\in p}
For each edge {\displaystyle (u,v)\in p}(u,v)\in p
{\displaystyle f(u,v)\leftarrow f(u,v)+c_{f}§}f(u,v)\leftarrow f(u,v)+c_{f}§ (Send flow along the path)
{\displaystyle f(v,u)\leftarrow f(v,u)-c_{f}§}f(v,u)\leftarrow f(v,u)-c_{f}§ (The flow might be “returned” later)
“←” denotes assignment. For instance, “largest ← item” means that the value of largest changes to the value of item.
“return” terminates the algorithm and outputs the following value.
The path in step 2 can be found with, for example, a breadth-first search (BFS) or a depth-first search in {\displaystyle G_{f}(V,E_{f})}G_{f}(V,E_{f}). If you use the former, the algorithm is called Edmonds–Karp.

When no more paths in step 2 can be found, s will not be able to reach t in the residual network. If S is the set of nodes reachable by s in the residual network, then the total capacity in the original network of edges from S to the remainder of V is on the one hand equal to the total flow we found from s to t, and on the other hand serves as an upper bound for all such flows. This proves that the flow we found is maximal. See also Max-flow Min-cut theorem.

If the graph {\displaystyle G(V,E)}G(V,E) has multiple sources and sinks, we act as follows: Suppose that {\displaystyle T={t\mid t{\text{ is a sink}}}}{\displaystyle T={t\mid t{\text{ is a sink}}}} and {\displaystyle S={s\mid s{\text{ is a source}}}}{\displaystyle S={s\mid s{\text{ is a source}}}}. Add a new source {\displaystyle s{*}}s{} with an edge {\displaystyle (s{*},s)}(s{},s) from {\displaystyle s{*}}s{} to every node {\displaystyle s\in S}s\in S, with capacity {\displaystyle c(s^{},s)=d_{s};(d_{s}=\sum {(s,u)\in E}c(s,u))}c(s^{*},s)=d{s};(d_{s}=\sum {(s,u)\in E}c(s,u)). And add a new sink {\displaystyle t{*}}t{} with an edge {\displaystyle (t,t{*})}(t,t{}) from every node {\displaystyle t\in T}t\in T to {\displaystyle t{*}}t{}, with capacity {\displaystyle c(t,t^{})=d{t};(d_{t}=\sum {(v,t)\in E}c(v,t))}c(t,t^{*})=d{t};(d_{t}=\sum _{(v,t)\in E}c(v,t)). Then apply the Ford–Fulkerson algorithm.

Also, if a node u has capacity constraint {\displaystyle d_{u}}d_{u}, we replace this node with two nodes {\displaystyle u_{\mathrm {in} },u_{\mathrm {out} }}{\displaystyle u_{\mathrm {in} },u_{\mathrm {out} }}, and an edge {\displaystyle (u_{\mathrm {in} },u_{\mathrm {out} })}{\displaystyle (u_{\mathrm {in} },u_{\mathrm {out} })}, with capacity {\displaystyle c(u_{\mathrm {in} },u_{\mathrm {out} })=d_{u}}{\displaystyle c(u_{\mathrm {in} },u_{\mathrm {out} })=d_{u}}. Then apply the Ford–Fulkerson algorithm.

2 Complexity

3 Integral example

4 Non-terminating example

5 Python implementation of Edmonds–Karp algorithm

6 See also

相关内容

热门资讯

解密科技赛道超额收益!顶尖基金... 2026年以来A股结构性行情极致演绎,主动权益基金业绩严重分化。数据显示,截至7月3日,主动权益基金...
证券板块为什么是“股市风向标”... 资本市场的长期投资价值对于证券公司的长期投资价值具有显著的正向带动作用。从收入构成中我们能够看到证券...
原创 年... 46% 的 Z 世代、35% 的千禧一代,延后了买房、结婚、生育这些人生重大决策。 听起来有点惨,但...
消息称SambaNova融资1... IT之家 7 月 8 日消息,据彭博社稍早前消息,AI 芯片企业 SambaNova 即将在当地时间...
利好突袭!A股盘中,直线拉升!... 云计算概念股异动! 今日(7月8日),云计算概念股集体拉升,板块指数涨幅超过4%,浪潮信息一字涨停,...
原创 传... 这几年喊了多年的美元霸权衰落,终于不再是空话。美国自己急得团团转,四处找新的货币锚点,还真折腾出几个...
韩国股市跌入技术性熊市,监管紧... 韩国股市正面临今年以来最严峻的考验,基准指数KOSPI从历史高点下跌20%,进入技术性熊市门槛,监管...
原创 美... 网上一直流传着一组扎心数据,即:中国居民可支配收入仅占GDP的比例45%左右,而美国却高达75%以上...
AI休整期不悲观,某些板块底部... 继续普调,严重缩量! 今日沪指跌1.26%、创业板跌0.94%、科创综指跌0.18%; 全天成交额...
知名经济学家高善文去世,曾预判... 出品|搜狐财经 作者|汪梦婷 7月7日,知名经济学家、原国投证券首席经济学家高善文不幸去世,享年55...
20万份文件泄密,苹果被坑惨了 苹果的机密在印度代工厂塔塔电子大面积泄露后,坐不住的不仅是库克,还有新德里的高官们。 当地时间7月2...
起点订购APP贵金属订购交易欺...   互联网上充斥着白银、铂金、铜等现货贵金属投资公司的宣传,通过不实的贵金属现货APP吸引投资者,但...
全新易购APP高额手续费的期货...   全新易购APP白银铂金现货订购出现严重的损失,投资者在这个平台根本赚不到钱,开始还好,后面的交易...
银行板块震荡上扬 中国银行等股... 观点网讯:7月8日,银行板块震荡上扬,中国银行、农业银行、建设银行、成都银行、工商银行等股纷纷上扬。...
AI Agent进入深水区:企... AI Agent从技术概念走向商业落地,企业付费意愿成为检验产品价值的唯一标准。过去两年大量AI创业...
一通智投APP内幕交易欺骗投资...   一通智投APP虚假现货订购交易为非法期货,投资者被宣传广告给诱导,下载了一通智投APP,结果在这...
港股科技股全线大涨!跌多了是基... 港股市场近日整体有明显反弹的科技股今日再度集体走强,恒生科技指数拉升涨超3%。个股中,联想涨超8%,...
一场博览会,看透低空经济风口全... 文丨许佳慧 低空经济风起,谁是真正的弄潮儿? 【观赛道:题材风口开启,全链布局成型】 低空经济有多火...
黄金单边牛市没那么快回来?预测... 黄金这波反弹刚冒头,没人敢直接砸重仓赌方向。Polymarket上的交易显示,黄金7月触及4300美...
超颖电子布局“A+H”:一季度... 瑞财经 吴文婷7月6日,超颖电子发布公告称,为满足公司业务发展需要,深入推进国际化战略,打造国际化资...