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

相关内容

热门资讯

蜻蜓订购APP贵金属订购非法期...   蜻蜓订购APP以"投资平台"名义对外宣传,主打贵金属期货(订购)交易。该平台一方面强调自身"正规...
悟空订购APP非法期货交易欺骗...   近期,有投资者反映,“悟空订购APP”等平台以白银、贵金属订购为名,宣传所谓“高收益”“低门槛”...
小赢淘金APP期货投资骗局,平...   “小赢淘金”之流,最擅长的就是用“注册送现金”、“充值返券”的糖衣炮弹来引流。别天真地以为那是福...
八方淘金APP非法期货交易欺骗...   警惕!八方生财、每日淘金、小赢淘金、悟空订购、蜻蜓订购、斗金订购等APP均涉嫌非法期货交易!  ...
智易购APP贵金属订购交易骗局...   很多人看到“3元起投”“充值送福利”“操作简单”“随时提现”这类宣传,很容易把智易购APP当成普...
喜玛银庄APP商品订购投资骗局...   喜玛银庄APP白银、铂金“现货订购”骗局警示:无资质平台涉嫌非法期货交易,投资者爆仓后如何维权?...
吉鑫乐享APP炒贵金属订购交易...   近期,多名投资者反映在“吉鑫乐享APP”进行贵金属投资时遭遇严重亏损,甚至血本无归。看似正规的“...
易掘金APP虚假期货投资骗局,...   “易掘金”的APP它打着“高收益、灵活投资”的旗号,宣称通过“商品订购”就能轻松赚钱,吸引了不少...
在大吉订购APP订购交易亏损被...   近期,不少投资者反映在“大吉订购App”上投资白银、铂金等商品遭遇严重亏损。该平台宣称提供现货订...
铂银壹号APP商品订购交易亏损...   许多中小投资者误以为网上的“商品现货订购”是合规合法的理财渠道,殊不知这背后隐藏着巨大的合规风险...
兴鑫淘金APP贵金属订购交易亏...   白银、贵金属或其他商品类投资,除国家批准的正规期货交易场所及持牌期货公司外,市面上大量第三方交易...
铂银掘金APP无资质的违规平台...   铂银掘金等平台的投资者,往往是被“注册送现金”“充值返现券”“首单免亏”等广告话术吸引,进而下载...
八方淘金APP订购交易不合规,...   “八方淘金APP”“铂银掘金APP”“铂银壹号APP”等软件被指以“现货订购”为名,实际采用高杠...
在指尖订购APP订购商品亏损被...   指尖订购APP这类平台,表面是“订购交易”,实则是披着电商外衣的非法期货陷阱。绝大多数投资者被蒙...
在犀贝易购APP做商品订购交易...   市面上打着“现货投资”“贵金属交易”旗号的APP并不少,但真正合规、受监管的平台并不多。犀贝易购...
易达淘金APP虚假商品订购交易...   易达淘金APP存在严重的虚假宣传与违规交易行为。该平台打着“商品订购”的旗号,实则通过不合规的交...
大浪淘金APP白银订购亏损被骗...   大浪淘金APP最隐蔽的套路,在于其完全封闭的内盘交易系统。表面上,它宣称与国际贵金属市场接轨;实...
一品好购APP上订购白银出现亏...   一品好购APP原名“一品订购”,运营方为上海宝智未来信息技术有限公司。近期不少投资者反映在该平台...
九州订购APP贵金属订购投资骗...   九州订购APP正通过抖.音、快手、今日头条等平台大量投放投资广告,用“5元起投”“充值返现”“0...
坚锅淘金APP交易软件并不正规...   当前,市面上大量所谓的“现货商城订购”交易软件,早已偏离了正常的实物商品买卖,演变为高杠杆、高手...