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

相关内容

热门资讯

广发银行全力打造服务粤港澳大湾... 建设粤港澳大湾区是国家重大区域发展战略。随着大湾区加快迈向国际一流湾区与世界级城市群,金融作为资源配...
北京抖音代运营代运营公司 1数字内容生产链中的专业化环节 在数字营销的生态中,存在一类专门负责内容平台账号系统性管理与内容...
2026年618有哪些值得关注... 先说一个容易被忽视的事实:618期间选返利平台,和日常选平台的标准完全不同。 日常购物,你关注的是返...
原创 今... 5月16日,国内黄金价格继续往下走,多家品牌金店的足金报价已经跌到1400元附近,比前一天低了十几元...
2026年华林电力专业配电柜批... 电力设备制造领域的品质标杆:深度解读一家专业企业的成长密码 配电柜如同电力系统的"神经中枢",其...
大调仓!伯克希尔开启后巴菲特时... 根据伯克希尔-哈撒韦公司15日向美国证券交易委员会提交的持仓文件,今年第一季度,公司对投资组合进行大...
原创 特... 图 | 美国总统特朗普 美国人突然发现了一个尴尬的现实,即中国不好啃,而欧洲却更像是一块摆在桌上的肥...
索罗斯基金一季度大举调仓!建仓... 日前,索罗斯基金(Soros Fund Management)向美国证券交易委员会(SEC)提交13...
下周外盘看点丨美联储公布会议纪... 本周国际市场风云变幻,全球债市发出危险信号。美股涨跌互现,道指周跌0.17%,纳指周跌0.08%,标...
“肯德基指数”回暖释放消费市场... 你身边肯定有这样的人,或者你本人就是这样: 点外卖先按价格排序,喝咖啡超过9块9就觉得亏了。但商家的...
反杀英伟达!亏损多年却一夜千亿... Cerebras 的纳斯达克上市大戏刚刚落幕,但其引发的连锁反应仍在持续发酵。 5 月 14 日上市...
从大客户依赖到募资补流 军陶科... 上市是一场马拉松! 作者:夏木 编辑:陶然 风品:李毅 来源:首财——首条财经研究院 念念不忘终有回...
原创 人... 近日人民币兑美元汇率持续攀升,先后突破6.8关口,离岸和在岸人民币双双刷新近三年来新高,引发市场高度...
证监会发布新规,11月16日起... 来源:证券日报之声 本报记者 吴晓璐 5月15日,中国证监会发布《衍生品交易监督管理办法(试行)》(...
广州东山口联排别墅集中法拍!9... 日前,位于广州市越秀区江岭下街的实地·紫薇公馆9套别墅,被挂上京东资产交易平台。9套东山口联排别墅起...
原创 黄... 近一年来,不少投资者感叹黄金价格走势的难以捉摸。每当感觉金价已涨至高位,它却往往能再创新高;而当投资...
原创 欧... IEEFA刚刚发布的一份报告,给欧洲引发关注。2021年至2025年间,欧洲从美国进口的液化天然气增...
霍尔木兹海峡,突传大消息!欧洲... 伊朗媒体:欧洲方面已开始就霍尔木兹海峡通行问题与革命卫队接触 伊朗伊斯兰共和国广播电视台16日就霍尔...
海南自贸港“样板间”抢抓开放机... 中新网海口5月16日电 (记者 王子谦)洋浦经济开发区是海南自贸港“样板间”,也是外界观察自贸港建设...
净利增速2.98%,违规频发!... 近期,中信银行2025年年报与2026年一季报接连公布,报告显示,中信银行总资产站稳10万亿元台阶,...