{"id":1859,"date":"2019-01-01T12:00:00","date_gmt":"2019-01-01T11:00:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/the-ford-fulkerson-algorithm\/"},"modified":"2026-07-05T03:20:52","modified_gmt":"2026-07-05T01:20:52","slug":"the-ford-fulkerson-algorithm","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/the-ford-fulkerson-algorithm\/","title":{"rendered":"The Ford-Fulkerson Algorithm"},"content":{"rendered":"<p>We now present the Ford-Fulkerson algorithm and a simple explanation. To follow this tutorial, you need to understand:<\/p>\n<ul>\n<li><a href=\"https:\/\/kindsonthegenius.com\/tempsite\/introduction-to-network-flow\/\">The Basics of Flow Networks<\/a><\/li>\n<li><a href=\"https:\/\/kindsonthegenius.com\/tempsite\/network-flow-introduction-to-cuts-in-a-network\/\">Max Flow Problem<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=7E9OWqcMTeI\" target=\"_blank\" rel=\"noopener\">Residual Graphs<\/a><\/li>\n<\/ul>\n<p>Take some time to review these prerequisite topics.<\/p>\n<p>Before we do that, recall the definition of bottleneck. A bottleneck(P, f) is defined on a path P(a simple path) on the residual graph as the minimum residual capacity on any edge of P with respect to the flow f.<\/p>\n<p>An s-t path in the residual graph is also known as an <strong>augmenting path<\/strong>.<\/p>\n<p>The Ford-Fulkerson algorithm proceeds by successively augmenting each edge on the path until no path exists between s and t in the residual graph.<\/p>\n<p>The augment procedure is given below.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #0066bb; font-weight: bold;\">augment<\/span>(f, <span style=\"color: #333399; font-weight: bold;\">P<\/span>)\n\t<span style=\"color: #333399; font-weight: bold;\">Set<\/span> b <span style=\"color: #000000; font-weight: bold;\">=<\/span> bottleneck(<span style=\"color: #333399; font-weight: bold;\">P<\/span>, f)\n\tfor each edge (u, v) \u2208 <span style=\"color: #333399; font-weight: bold;\">P<\/span>\n\t\t<span style=\"color: #008800; font-weight: bold;\">if<\/span> (u, v) is a forward edge <span style=\"color: #008800; font-weight: bold;\">then<\/span>\n\t\t\tincrease f(e) <span style=\"color: #008800; font-weight: bold;\">in<\/span> <span style=\"color: #333399; font-weight: bold;\">G<\/span> by b\n\t\t<span style=\"color: #008800; font-weight: bold;\">else<\/span> (u, v) is a backward edge\n\t\t\treduce f(e) <span style=\"color: #008800; font-weight: bold;\">in<\/span> <span style=\"color: #333399; font-weight: bold;\">G<\/span> \n\t\t<span style=\"color: #333399; font-weight: bold;\">Endif<\/span>\n\t<span style=\"color: #333399; font-weight: bold;\">Endfor<\/span>\n<span style=\"color: #333399; font-weight: bold;\">Return<\/span>(f)\n<\/pre>\n<\/div>\n<p>Listing 1.0: The augment procedure<\/p>\n<p>Note that the augment procedure is performed in the residual graph to produce a flow in G. Now this augmentation procedure has to be repeated until we obtain the max-flow for G. This is a point where we can no longer find an s-t path in the residual graph.<\/p>\n<p>The algorithm for finding the max-flow is given in Listing 1.1.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<div style=\"background: #ffffff; overflow: auto; width: auto; border: solid gray; border-width: .1em .1em .1em .8em; padding: .2em .6em;\">\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #333399; font-weight: bold;\">Max<\/span><span style=\"color: #333333;\">-<\/span><span style=\"color: #333399; font-weight: bold;\">Flow<\/span>\n\t<span style=\"color: #333399; font-weight: bold;\">Initially<\/span> set f(e) <span style=\"color: #000000; font-weight: bold;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">0<\/span> for all e <span style=\"color: #008800; font-weight: bold;\">in<\/span> <span style=\"color: #333399; font-weight: bold;\">G<\/span>\n\twhile there is an s<span style=\"color: #333333;\">-<\/span>t path <span style=\"color: #008800; font-weight: bold;\">in<\/span> the residual graph <span style=\"color: #333399; font-weight: bold;\">Gf<\/span>\n\t\t<span style=\"color: #333399; font-weight: bold;\">Let<\/span> <span style=\"color: #333399; font-weight: bold;\">P<\/span> be a simple s<span style=\"color: #333333;\">-<\/span>t path <span style=\"color: #008800; font-weight: bold;\">in<\/span> <span style=\"color: #333399; font-weight: bold;\">Gf<\/span>\n\t\tf' <span style=\"color: #000000; font-weight: bold;\">=<\/span> augment(f, <span style=\"color: #333399; font-weight: bold;\">P<\/span>)\n\t\t<span style=\"color: #333399; font-weight: bold;\">Update<\/span> f to be f'\n\t\t<span style=\"color: #333399; font-weight: bold;\">Update<\/span> the residual graph <span style=\"color: #333399; font-weight: bold;\">Gf<\/span> to be <span style=\"color: #333399; font-weight: bold;\">Gf'<\/span>\n\t<span style=\"color: #333399; font-weight: bold;\">Endwhile<\/span>\n\t<span style=\"color: #333399; font-weight: bold;\">Return<\/span> f\n<\/pre>\n<\/div>\n<p>Listing 1.1: The Max-Flow Algorithm<\/p>\n<p>This Max-Flow algorithm is the Ford-Fulkerson algorithm.<\/p>\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=MIauBXEu3BU&amp;t=10s\" target=\"_blank\" rel=\"noopener\"><strong>Watch the Video Explanation<\/strong><\/a><\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/MIauBXEu3BU\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>We now present the Ford-Fulkerson algorithm and a simple explanation. To follow this tutorial, you need to understand: The Basics of Flow Networks Max Flow &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[35],"tags":[],"class_list":["post-1859","post","type-post","status-publish","format-standard","hentry","category-algorithms"],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1859","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=1859"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1859\/revisions"}],"predecessor-version":[{"id":2028,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1859\/revisions\/2028"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=1859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=1859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=1859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}