Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Edmonds–Karp algorithm
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==Example== Given a network of seven nodes, source A, sink G, and capacities as shown below: [[Image:Edmonds-Karp flow example 0.svg|300px|class=skin-invert-image]] In the pairs <math>f/c</math> written on the edges, <math>f</math> is the current flow, and <math>c</math> is the capacity. The residual capacity from <math>u</math> to <math>v</math> is <math>c_f(u,v)=c(u,v)-f(u,v)</math>, the total capacity, minus the flow that is already used. If the net flow from <math>u</math> to <math>v</math> is negative, it ''contributes'' to the residual capacity. {| class="wikitable" |- ! Path ! Capacity ! Resulting network |- | align="center" | <math>A,D,E,G</math> | <math>\begin{align} & \min(c_f(A,D),c_f(D,E),c_f(E,G)) \\ = & \min(3-0,2-0,1-0) \\ = & \min(3,2,1) = 1 \end{align}</math> | [[Image:Edmonds-Karp flow example 1.svg|300px|class=skin-invert-image]]</td> |- | align="center" | <math>A,D,F,G</math> | <math>\begin{align} & \min(c_f(A,D),c_f(D,F),c_f(F,G)) \\ = & \min(3-1,6-0,9-0) \\ = & \min(2,6,9) = 2 \end{align}</math> | [[Image:Edmonds-Karp flow example 2.svg|300px|class=skin-invert-image]]</td> |- | align="center" | <math>A,B,C,D,F,G</math> | <math>\begin{align} & \min(c_f(A,B),c_f(B,C),c_f(C,D),c_f(D,F),c_f(F,G)) \\ = & \min(3-0,4-0,1-0,6-2,9-2) \\ = & \min(3,4,1,4,7) = 1 \end{align}</math> | [[Image:Edmonds-Karp flow example 3.svg|300px|class=skin-invert-image]]</td> |- | align="center" | <math>A,B,C,E,D,F,G</math> | <math>\begin{align} & \min(c_f(A,B),c_f(B,C),c_f(C,E),c_f(E,D),c_f(D,F),c_f(F,G)) \\ = & \min(3-1,4-1,2-0,0-(-1),6-3,9-3) \\ = & \min(2,3,2,1,3,6) = 1 \end{align}</math> | [[Image:Edmonds-Karp flow example 4.svg|300px|class=skin-invert-image]]</td> |} Notice how the length of the [[augmenting path]] found by the algorithm (in red) never decreases. The paths found are the shortest possible. The flow found is equal to the capacity across the [[max flow min cut theorem|minimum cut]] in the graph separating the source and the sink. There is only one minimal cut in this graph, partitioning the nodes into the sets <math>\{A,B,C,E\}</math> and <math>\{D,F,G\}</math>, with the capacity :<math>c(A,D)+c(C,D)+c(E,G)=3+1+1=5.\ </math>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)