Network Flow Problems: Ford-Fulkerson Algorithm and Min-Cost Max-Flow, Study notes of Computer Science

An overview of network flow problems, focusing on the ford-fulkerson algorithm and min-cost max-flow. Network flow problems arise in various contexts, such as routing packets in networks or sending trucks on roads. The settings, constraints, and solutions for these problems, including the ford-fulkerson algorithm's pseudocode and analysis.

Typology: Study notes

2017/2018

Uploaded on 11/05/2018

sadekujjaman
sadekujjaman 🇧🇩

1 document

1 / 26

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Network Flow Problems
Jaehyun Park
CS 97SI
Stanford University
June 29, 2015
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a

Partial preview of the text

Download Network Flow Problems: Ford-Fulkerson Algorithm and Min-Cost Max-Flow and more Study notes Computer Science in PDF only on Docsity!

Network Flow Problems

Jaehyun Park

CS 97SI

Stanford University

June 29, 2015

Outline

Network Flow Problems

Ford-Fulkerson Algorithm

Bipartite Matching

Min-cost Max-flow Algorithm

Network Flow Problems 2

Network Flow Problem

◮ Settings: Given a directed graph G = ( V, E ), where each edge

e is associated with its capacity c ( e ) > 0. Two special nodes

source s and sink t are given ( s 6 = t )

◮ Problem: Maximize the total amount of flow from s to t

subject to two constraints

  • Flow on edge e doesn’t exceed c ( e )
  • For every node v 6 = s, t , incoming flow is equal to outgoing flow

Network Flow Problems 4

Network Flow Example (from CLRS)

◮ Capacities

◮ Maximum flow (of 23 total units)

Network Flow Problems 5

Minimum Cut Example

◮ Capacities

◮ Minimum Cut (red edges are removed)

Network Flow Problems 7

Flow Decomposition

◮ Any valid flow can be decomposed into flow paths and

circulations

  • sabt : 11
  • scabt : 1
  • scdbt : 7
  • scdt : 4

Network Flow Problems 8

Ford-Fulkerson Algorithm

◮ A simple and practical max-flow algorithm

◮ Main idea: find valid flow paths until there is none left, and

add them up

◮ How do we know if this gives a maximum flow?

  • Proof sketch: Suppose not. Take a maximum flow f ⋆^ and “subtract” our flow f. It is a valid flow of positive total flow. By the flow decomposition, it can be decomposed into flow paths and circulations. These flow paths must have been found by Ford-Fulkerson. Contradiction.

Ford-Fulkerson Algorithm 10

Back Edges

◮ We don’t need to maintain the amount of flow on each edge

but work with capacity values directly

◮ If f amount of flow goes through u → v , then:

  • Decrease c ( uv ) by f
  • Increase c ( vu ) by f

◮ Why do we need to do this?

  • Sending flow to both directions is equivalent to canceling flow

Ford-Fulkerson Algorithm 11

Analysis

◮ Assumption: capacities are integer-valued

◮ Finding a flow path takes Θ( n + m ) time

◮ We send at least 1 unit of flow through the path

◮ If the max-flow is f ⋆ , the time complexity is O (( n + m ) f ⋆ )

  • “Bad” in that it depends on the output of the algorithm
  • Nonetheless, easy to code and works well in practice

Ford-Fulkerson Algorithm 13

Computing Min-Cut

◮ We know that max-flow is equal to min-cut

◮ And we now know how to find the max-flow

◮ Question: how do we find the min-cut?

◮ Answer: use the residual graph

Ford-Fulkerson Algorithm 14

Computing Min-Cut

◮ Mark all nodes reachable from s

  • Call the set of reachable nodes A

◮ Now separate these nodes from the others

  • Cut edges going from A to VA

Ford-Fulkerson Algorithm 16

Computing Min-Cut

◮ Look at the original graph and find the cut:

◮ Why isn’t b → c cut?

Ford-Fulkerson Algorithm 17

Bipartite Matching

◮ Settings:

  • n students and d dorms
  • Each student wants to live in one of the dorms of his choice
  • Each dorm can accommodate at most one student (?!) ◮ (^) Fine, we will fix this later...

◮ Problem: find an assignment that maximizes the number of

students who get a housing

Bipartite Matching 19

Flow Network Construction

◮ Add source and sink

◮ Make edges between students and dorms

  • All the edge weights are 1

Bipartite Matching 20