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

相关内容

热门资讯

简单的脑力训练 坚持下去就能助... 阿尔茨海默病作为一种神经退行性改变,其病理进程在临床症状出现前数十年便已悄然启动。这一过程的核心特征...
SpaceX合并xAI,马斯克... 马斯克认为商业航天加人工智能的新模式有利于打造太空数据中心,新公司估值1.25万亿美元,离IPO又近...
品浩艾达信:高科技行业会继续吸... 品浩集团(PIMCO)投资总监兼董事总经理艾达信近日在上海表示,高科技行业会持续驱动经济增长,也会继...
19人被判刑!北京长峰医院火灾... 据北京丰台区法院消息,2026年2月2日,北京市丰台区人民法院对北京长峰医院火灾案件进行公开宣判,被...
机构1月调研动向曝光!银行业调... 机构去哪儿? 2026年1月,不少机构马不停蹄地进行调研,寻找新一年A股市场投资机会,其间合计有超过...
融资丨宠食品牌都乐时母公司逢时... 作者:子超@宠业家 【写在前面】 宠业家「融资栏目」,为关注宠物投融资动态的朋友,带来行业内最新宠物...
*ST立方:停牌核查结束 股票... 每经AI快讯,2月3日,*ST立方(300344.SZ)公告称,停牌期间,公司就股价波动的相关事项进...
开年看楼市·政策友好带动市场成... 央视网消息:北京市住建委最新数据显示,1月,北京二手住宅网签量达1.5万套,这是2025年12月以来...
昨天ICU今天KTV!连续大跌... 记者|黄胜 编辑|程鹏 杜恒峰 校对|陈柯名 北京时间2月3日晚间,连续3日下跌后,国际金银价格迎来...
潮白河畔的白色港湾:这里守护着... 潮白河畔的白色港湾:这里守护着1000万精神障碍老人的尊严 在京津冀交界的潮白河西岸,一座白色庭院静...
2月4日A股投资避雷针︱耐普矿... 商络电子实际控制人拟减持不超过3%股份;壹连科技股东长江晨道拟减持不超过2%股份;富瀚微实际控制人的...
开年狂申报237只!基金公司竞... 2026年A股喜迎开门红,上证指数接连突破4000点、4100点关口,创下十年新高,罕见的“17连阳...
腾讯首席AI科学家姚顺雨入职后... IT之家 2 月 3 日消息,腾讯混元官网技术博客(Tencent HY Research)今日(2...
预定利率“2时代”现高收益健康... 2026年开年,保险市场诞生了一款热门产品。《每日经济新闻》记者(以下简称每经记者)从业内获悉,平安...
二手房市场回暖 房贷利率或继续... 制图:黄亚岚(即梦AI生成) 近日,国家统计局公布了2025年全年的经济数据,其中房地产市场数据备...
SpaceX与AI初创公司xA... 据报道,SpaceX正与人工智能初创公司xAI进行深入合并谈判。消息称,双方有望在本周达成协议,尽管...
国资委披露87家央企负责人激励... 据国务院国资委网站2月3日消息,按照中央企业负责人薪酬管理有关规定,中央企业负责人薪酬总收入由年度薪...
券商297只金股出炉!贵州茅台... 2月3日,A股市场探底回升,三大指数均迎来上涨。截至收盘,沪指报4067.74点,当日上涨1.29%...
白癜风专家祃开芬:白癜风与饮食... 饮食均衡是白癜风患者全身调理的基础,能为黑色素合成提供充足原料、稳定免疫功能,避免单一饮食或盲目忌口...
韩建河山拟收购兴福新材99.9... 2月3日,韩建河山(603616.SH)公告称,拟发行股份及支付现金购买兴福新材99.9978%股份...