SlideShare a Scribd company logo
Maximum Flow
Chapter 26
Flow Graph
• A common scenario is to use a graph to
represent a “flow network” and use it to answer
questions about material flows
• Flow is the rate that material moves through the
network
• Each directed edge is a conduit for the material
with some stated capacity
• Vertices are connection points but do not collect
material
– Flow into a vertex must equal the flow leaving the
vertex, flow conservation
Sample Networks
communication
Network
telephone exchanges,
computers, satellites
Nodes Arcs
cables, fiber optics,
microwave relays
Flow
voice, video,
packets
circuits
gates, registers,
processors
wires current
mechanical joints rods, beams, springs heat, energy
hydraulic
reservoirs, pumping
stations, lakes
pipelines fluid, oil
financial stocks, companies transactions money
transportation
airports, rail yards,
street intersections
highways, railbeds,
airway routes
freight,
vehicles,
passengers
chemical sites bonds energy
Flow Concepts
• Source vertex s
– where material is produced
• Sink vertex t
– where material is consumed
• For all other vertices – what goes in must go out
– Flow conservation
• Goal: determine maximum rate of material
flow from source to sink
Formal Max Flow Problem
– Graph G=(V,E) – a flow network
• Directed, each edge has capacity c(u,v)  0
• Two special vertices: source s, and sink t
• For any other vertex v, there is a path s…v…t
– Flow – a function f : V  V R
• Capacity constraint: For all u, v  V: f(u,v)  c(u,v)
• Skew symmetry: For all u, v  V: f(u,v) = –f(v,u)
• Flow conservation: For all u  V – {s, t}:
, or( , ) ( , ) 0
( , ) ( , ) 0
v V
v V
f u v f u V
f v u f V u


 
 

2/5
2/15
5/14
4/19
3/3
s t0/9
a
b
Cancellation of flows
• We would like to avoid two positive flows
in opposite directions between the same
pair of vertices
– Such flows cancel (maybe partially) each
other due to skew symmetry
5/5
2/15
5/14
5/19
2/3
s t2/9
a
b
3/5
2/15
5/14
5/19
2/3
s t0/9
a
b
Max Flow
• We want to find a flow of maximum value
from the source to the sink
– Denoted by |f|
Lucky Puck Distribution Network Max Flow, |f| = 19
Or is it?
Best we can do?
Ford-Fulkerson method
• Contains several algorithms:
– Residue networks
– Augmenting paths
• Find a path p from s to t (augmenting path), such that there is
some value x > 0, and for each edge (u,v) in p we can add x
units of flow
– f(u,v) + x  c(u,v)
8/13
8/11
5/52/4
10/15
10
6/14
13/19
3/3
s t9
a b
c d
Augmenting Path?
Residual Network
• To find augmenting path we can find any path in the
residual network:
– Residual capacities: cf(u,v) = c(u,v) – f(u,v)
• i.e. the actual capacity minus the net flow from u to v
• Net flow may be negative
– Residual network: Gf =(V,Ef), where
Ef = {(u,v)  V  V : cf(u,v) > 0}
– Observation – edges in Ef are either edges in E or their
reversals: |Ef|  2|E|
0/14
5/15
a b
19
10
a b
Sub-graph
With
c(u,v) and
f(u,v)
Residual
Sub-Graph
c
5/6
c
1
5
Residual Graph
• Compute the residual graph of the graph with the
following flow:
8/13
8/11
5/52/4
10/15
10
6/14
13/19
3/3
s t9
a b
c d
Residual Capacity and Augmenting
Path
• Finding an Augmenting Path
– Find a path from s to t in the residual graph
– The residual capacity of a path p in Gf:
cf(p) = min{cf(u,v): (u,v) is in p}
• i.e. find the minimum capacity along p
– Doing augmentation: for all (u,v) in p, we just
add this cf(p) to f(u,v) (and subtract it from
f(v,u))
– Resulting flow is a valid flow with a larger
value.
Residual network and augmenting path
The Ford-Fulkerson method
Ford-Fulkerson(G,s,t)
1 for each edge (u,v) in G.E do
2 f(u,v)  f(v,u)  0
3 while there exists a path p from s to t in residual
network Gf do
4 cf = min{cf(u,v): (u,v) is in p}
5 for each edge (u,v) in p do
6 f(u,v)  f(u,v) + cf
7 f(v,u)  -f(u,v)
8 return f
The algorithms based on this method differ in how they choose p in step 3.
If chosen poorly the algorithm might not terminate.
Execution of Ford-Fulkerson (1)
Left Side = Residual Graph Right Side = Augmented Flow
Execution of Ford-Fulkerson (2)
Left Side = Residual Graph Right Side = Augmented Flow
Cuts
• Does the method find the minimum flow?
– Yes, if we get to the point where the residual graph has no path from s
to t
– A cut is a partition of V into S and T = V – S, such that s  S and t  T
– The net flow (f(S,T)) through the cut is the sum of flows f(u,v), where s
 S and t  T
• Includes negative flows back from T to S
– The capacity (c(S,T)) of the cut is the sum of capacities c(u,v), where s
 S and t  T
• The sum of positive capacities
– Minimum cut – a cut with the smallest capacity of all cuts.
|f|= f(S,T) i.e. the value of a max flow is equal to the capacity of a min
cut.
8/13
8/11
5/52/4
10/15
10
6/14
13/19
3/3
s t9
a b
c d
Cut capacity = 24 Min Cut capacity = 21
Max Flow / Min Cut Theorem
1. Since |f|  c(S,T) for all cuts of (S,T) then if |f| =
c(S,T) then c(S,T) must be the min cut of G
2. This implies that f is a maximum flow of G
3. This implies that the residual network Gf
contains no augmenting paths.
• If there were augmenting paths this would contradict
that we found the maximum flow of G
• 1231 … and from 23 we have that
the Ford Fulkerson method finds the maximum
flow if the residual graph has no augmenting
paths.
Worst Case Running Time
• Assuming integer flow
• Each augmentation increases the value of the flow by
some positive amount.
• Augmentation can be done in O(E).
• Total worst-case running time O(E|f*|), where f* is the
max-flow found by the algorithm.
• Example of worst case:
Augmenting path of 1 Resulting Residual Network Resulting Residual Network
Edmonds Karp
• Take shortest path (in terms of number of
edges) as an augmenting path –
Edmonds-Karp algorithm
– How do we find such a shortest path?
– Running time O(VE2), because the number of
augmentations is O(VE)
– Skipping the proof here
– Even better method: push-relabel, O(V2E)
runtime
Multiple Sources or Sinks
• What if you have a problem with more than one source
and more than one sink?
• Modify the graph to create a single supersource and
supersink
13
11
54
15
10
14
13
3
s t9
a b
c d
13
11
54
15
10
14
13
3
x y9
e f
g h
4
13
11
54
15
10
14
13
3
9
a b
c d
13
11
54
15
10
14
13
3
9
e f
g h
4s
i
j
k
l
t




Application – Bipartite Matching
• Example – given a community with n men and m
women
• Assume we have a way to determine which
couples (man/woman) are compatible for
marriage
– E.g. (Joe, Susan) or (Fred, Susan) but not (Frank,
Susan)
• Problem: Maximize the number of marriages
– No polygamy allowed
– Can solve this problem by creating a flow network out
of a bipartite graph
Bipartite Graph
• A bipartite graph is an undirected graph G=(V,E) in
which V can be partitioned into two sets V1 and V2 such
that (u,v)  E implies either u  V1 and v  V12 or vice
versa.
• That is, all edges go between the two sets V1 and V2 and
not within V1 and V2.
Model for Matching Problem
• Men on leftmost set, women on rightmost
set, edges if they are compatible
A
B
C
D
X
Y
Z
Men Women
A
B
C
D
X
Y
Z
A matching
A
B
C
D
X
Y
Z
Optimal matching
Solution Using Max Flow
• Add a supersouce, supersink, make each
undirected edge directed with a flow of 1
A
B
C
D
X
Y
Z
A
B
C
D
X
Y
Z
s
t
Since the input is 1, flow conservation prevents multiple matchings

More Related Content

What's hot

Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
Amit Kumar Rathi
 
Approximation Algorithms
Approximation AlgorithmsApproximation Algorithms
Approximation Algorithms
Nicolas Bettenburg
 
Approximation algorithms
Approximation algorithmsApproximation algorithms
Approximation algorithms
Ganesh Solanke
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
Muhammad Amjad Rana
 
Network flows
Network flowsNetwork flows
Network flows
Luckshay Batra
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
Bhavik Vashi
 
Lecture28 tsp
Lecture28 tspLecture28 tsp
Network flows
Network flowsNetwork flows
Network flows
Richa Bandlas
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
Md. Shafiuzzaman Hira
 
Job sequencing with Deadlines
Job sequencing with DeadlinesJob sequencing with Deadlines
Job sequencing with Deadlines
YashiUpadhyay3
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
AnuragChaudhary70
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy Algorithm
Waqar Akram
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
Animesh Chaturvedi
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
Tech_MX
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
Subrata Kumer Paul
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
Bhavin Darji
 
A Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing NetworkA Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing Network
Shethwala Ridhvesh
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
Hinal Lunagariya
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
Dr. C.V. Suresh Babu
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
mansab MIRZA
 

What's hot (20)

Shortest path algorithms
Shortest path algorithmsShortest path algorithms
Shortest path algorithms
 
Approximation Algorithms
Approximation AlgorithmsApproximation Algorithms
Approximation Algorithms
 
Approximation algorithms
Approximation algorithmsApproximation algorithms
Approximation algorithms
 
Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Network flows
Network flowsNetwork flows
Network flows
 
Kruskal Algorithm
Kruskal AlgorithmKruskal Algorithm
Kruskal Algorithm
 
Lecture28 tsp
Lecture28 tspLecture28 tsp
Lecture28 tsp
 
Network flows
Network flowsNetwork flows
Network flows
 
SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS SINGLE-SOURCE SHORTEST PATHS
SINGLE-SOURCE SHORTEST PATHS
 
Job sequencing with Deadlines
Job sequencing with DeadlinesJob sequencing with Deadlines
Job sequencing with Deadlines
 
Bellman ford algorithm
Bellman ford algorithmBellman ford algorithm
Bellman ford algorithm
 
Greedy Algorithm
Greedy AlgorithmGreedy Algorithm
Greedy Algorithm
 
P, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-HardP, NP, NP-Complete, and NP-Hard
P, NP, NP-Complete, and NP-Hard
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Shortest path algorithm
Shortest  path algorithmShortest  path algorithm
Shortest path algorithm
 
Introduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of OptimalityIntroduction to Dynamic Programming, Principle of Optimality
Introduction to Dynamic Programming, Principle of Optimality
 
A Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing NetworkA Maximum Flow Min cut theorem for Optimizing Network
A Maximum Flow Min cut theorem for Optimizing Network
 
Minimum spanning tree
Minimum spanning treeMinimum spanning tree
Minimum spanning tree
 
Randomized algorithms ver 1.0
Randomized algorithms ver 1.0Randomized algorithms ver 1.0
Randomized algorithms ver 1.0
 
Dijkstra s algorithm
Dijkstra s algorithmDijkstra s algorithm
Dijkstra s algorithm
 

Similar to Maxflow

Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network Talk
Imane Haf
 
MaximumFlow.ppt
MaximumFlow.pptMaximumFlow.ppt
MaximumFlow.ppt
KrishanPalSingh39
 
lecture8-final.pdf ( analysis and design of algorithm)
lecture8-final.pdf ( analysis and design of algorithm)lecture8-final.pdf ( analysis and design of algorithm)
lecture8-final.pdf ( analysis and design of algorithm)
ZainabShahzad9
 
maxflow.4up.pdf for the Maximam flow to solve using flord fulkerson algorithm
maxflow.4up.pdf for the Maximam flow to solve using flord fulkerson algorithmmaxflow.4up.pdf for the Maximam flow to solve using flord fulkerson algorithm
maxflow.4up.pdf for the Maximam flow to solve using flord fulkerson algorithm
ZainabShahzad9
 
08-network-flow-problems that are usefull in Oops
08-network-flow-problems that are usefull in Oops08-network-flow-problems that are usefull in Oops
08-network-flow-problems that are usefull in Oops
sj7033742
 
Network flow problems
Network flow problemsNetwork flow problems
Network flow problems
Dr Sandeep Kumar Poonia
 
22 - Max Flow Porblem Ford Fulkerson Method.pdf
22 - Max Flow Porblem Ford Fulkerson Method.pdf22 - Max Flow Porblem Ford Fulkerson Method.pdf
22 - Max Flow Porblem Ford Fulkerson Method.pdf
abeedmaleek
 
Minimum cost maximum flow
Minimum cost maximum flowMinimum cost maximum flow
Minimum cost maximum flow
SaruarChowdhury
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cut
Mayank Garg
 
Max Flow Problem
Max Flow ProblemMax Flow Problem
Max Flow Problem
Guillaume Guérard
 
maxflow.ppt
maxflow.pptmaxflow.ppt
maxflow.ppt
ssuser8244a91
 
L21-MaxFlowPr.ppt
L21-MaxFlowPr.pptL21-MaxFlowPr.ppt
L21-MaxFlowPr.ppt
KrishanPalSingh39
 
aads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdfaads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdf
NanaKoori
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
Programming Homework Help
 
Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...
csandit
 
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
cscpconf
 
Ford Fulkerson Algorithm
Ford Fulkerson AlgorithmFord Fulkerson Algorithm
Ford Fulkerson Algorithm
Adarsh Rotte
 
Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12
Traian Rebedea
 
bellman-ford Theorem.ppt
bellman-ford Theorem.pptbellman-ford Theorem.ppt
bellman-ford Theorem.ppt
SaimaShaheen14
 
Day 5 application of graph ,biconnectivity fdp on ds
Day 5 application of graph ,biconnectivity fdp on dsDay 5 application of graph ,biconnectivity fdp on ds
Day 5 application of graph ,biconnectivity fdp on ds
GUNASUNDARISAPIIICSE
 

Similar to Maxflow (20)

Flow Network Talk
Flow Network TalkFlow Network Talk
Flow Network Talk
 
MaximumFlow.ppt
MaximumFlow.pptMaximumFlow.ppt
MaximumFlow.ppt
 
lecture8-final.pdf ( analysis and design of algorithm)
lecture8-final.pdf ( analysis and design of algorithm)lecture8-final.pdf ( analysis and design of algorithm)
lecture8-final.pdf ( analysis and design of algorithm)
 
maxflow.4up.pdf for the Maximam flow to solve using flord fulkerson algorithm
maxflow.4up.pdf for the Maximam flow to solve using flord fulkerson algorithmmaxflow.4up.pdf for the Maximam flow to solve using flord fulkerson algorithm
maxflow.4up.pdf for the Maximam flow to solve using flord fulkerson algorithm
 
08-network-flow-problems that are usefull in Oops
08-network-flow-problems that are usefull in Oops08-network-flow-problems that are usefull in Oops
08-network-flow-problems that are usefull in Oops
 
Network flow problems
Network flow problemsNetwork flow problems
Network flow problems
 
22 - Max Flow Porblem Ford Fulkerson Method.pdf
22 - Max Flow Porblem Ford Fulkerson Method.pdf22 - Max Flow Porblem Ford Fulkerson Method.pdf
22 - Max Flow Porblem Ford Fulkerson Method.pdf
 
Minimum cost maximum flow
Minimum cost maximum flowMinimum cost maximum flow
Minimum cost maximum flow
 
Max flow min cut
Max flow min cutMax flow min cut
Max flow min cut
 
Max Flow Problem
Max Flow ProblemMax Flow Problem
Max Flow Problem
 
maxflow.ppt
maxflow.pptmaxflow.ppt
maxflow.ppt
 
L21-MaxFlowPr.ppt
L21-MaxFlowPr.pptL21-MaxFlowPr.ppt
L21-MaxFlowPr.ppt
 
aads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdfaads_assignment1_answer-1.pdf
aads_assignment1_answer-1.pdf
 
Design and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment HelpDesign and Analysis of Algorithms Assignment Help
Design and Analysis of Algorithms Assignment Help
 
Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...Sequential and parallel algorithm to find maximum flow on extended mixed netw...
Sequential and parallel algorithm to find maximum flow on extended mixed netw...
 
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
SEQUENTIAL AND PARALLEL ALGORITHM TO FIND MAXIMUM FLOW ON EXTENDED MIXED NETW...
 
Ford Fulkerson Algorithm
Ford Fulkerson AlgorithmFord Fulkerson Algorithm
Ford Fulkerson Algorithm
 
Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12Algorithm Design and Complexity - Course 12
Algorithm Design and Complexity - Course 12
 
bellman-ford Theorem.ppt
bellman-ford Theorem.pptbellman-ford Theorem.ppt
bellman-ford Theorem.ppt
 
Day 5 application of graph ,biconnectivity fdp on ds
Day 5 application of graph ,biconnectivity fdp on dsDay 5 application of graph ,biconnectivity fdp on ds
Day 5 application of graph ,biconnectivity fdp on ds
 

Recently uploaded

DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
ijaia
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
MadhavJungKarki
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
Nada Hikmah
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
mahaffeycheryld
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
Paris Salesforce Developer Group
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
21UME003TUSHARDEB
 
TIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptxTIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptx
CVCSOfficial
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
upoux
 

Recently uploaded (20)

DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
 
Curve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods RegressionCurve Fitting in Numerical Methods Regression
Curve Fitting in Numerical Methods Regression
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
AI + Data Community Tour - Build the Next Generation of Apps with the Einstei...
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Mechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdfMechanical Engineering on AAI Summer Training Report-003.pdf
Mechanical Engineering on AAI Summer Training Report-003.pdf
 
TIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptxTIME TABLE MANAGEMENT SYSTEM testing.pptx
TIME TABLE MANAGEMENT SYSTEM testing.pptx
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
一比一原版(osu毕业证书)美国俄勒冈州立大学毕业证如何办理
 

Maxflow

  • 2. Flow Graph • A common scenario is to use a graph to represent a “flow network” and use it to answer questions about material flows • Flow is the rate that material moves through the network • Each directed edge is a conduit for the material with some stated capacity • Vertices are connection points but do not collect material – Flow into a vertex must equal the flow leaving the vertex, flow conservation
  • 3. Sample Networks communication Network telephone exchanges, computers, satellites Nodes Arcs cables, fiber optics, microwave relays Flow voice, video, packets circuits gates, registers, processors wires current mechanical joints rods, beams, springs heat, energy hydraulic reservoirs, pumping stations, lakes pipelines fluid, oil financial stocks, companies transactions money transportation airports, rail yards, street intersections highways, railbeds, airway routes freight, vehicles, passengers chemical sites bonds energy
  • 4. Flow Concepts • Source vertex s – where material is produced • Sink vertex t – where material is consumed • For all other vertices – what goes in must go out – Flow conservation • Goal: determine maximum rate of material flow from source to sink
  • 5. Formal Max Flow Problem – Graph G=(V,E) – a flow network • Directed, each edge has capacity c(u,v)  0 • Two special vertices: source s, and sink t • For any other vertex v, there is a path s…v…t – Flow – a function f : V  V R • Capacity constraint: For all u, v  V: f(u,v)  c(u,v) • Skew symmetry: For all u, v  V: f(u,v) = –f(v,u) • Flow conservation: For all u  V – {s, t}: , or( , ) ( , ) 0 ( , ) ( , ) 0 v V v V f u v f u V f v u f V u        2/5 2/15 5/14 4/19 3/3 s t0/9 a b
  • 6. Cancellation of flows • We would like to avoid two positive flows in opposite directions between the same pair of vertices – Such flows cancel (maybe partially) each other due to skew symmetry 5/5 2/15 5/14 5/19 2/3 s t2/9 a b 3/5 2/15 5/14 5/19 2/3 s t0/9 a b
  • 7. Max Flow • We want to find a flow of maximum value from the source to the sink – Denoted by |f| Lucky Puck Distribution Network Max Flow, |f| = 19 Or is it? Best we can do?
  • 8. Ford-Fulkerson method • Contains several algorithms: – Residue networks – Augmenting paths • Find a path p from s to t (augmenting path), such that there is some value x > 0, and for each edge (u,v) in p we can add x units of flow – f(u,v) + x  c(u,v) 8/13 8/11 5/52/4 10/15 10 6/14 13/19 3/3 s t9 a b c d Augmenting Path?
  • 9. Residual Network • To find augmenting path we can find any path in the residual network: – Residual capacities: cf(u,v) = c(u,v) – f(u,v) • i.e. the actual capacity minus the net flow from u to v • Net flow may be negative – Residual network: Gf =(V,Ef), where Ef = {(u,v)  V  V : cf(u,v) > 0} – Observation – edges in Ef are either edges in E or their reversals: |Ef|  2|E| 0/14 5/15 a b 19 10 a b Sub-graph With c(u,v) and f(u,v) Residual Sub-Graph c 5/6 c 1 5
  • 10. Residual Graph • Compute the residual graph of the graph with the following flow: 8/13 8/11 5/52/4 10/15 10 6/14 13/19 3/3 s t9 a b c d
  • 11. Residual Capacity and Augmenting Path • Finding an Augmenting Path – Find a path from s to t in the residual graph – The residual capacity of a path p in Gf: cf(p) = min{cf(u,v): (u,v) is in p} • i.e. find the minimum capacity along p – Doing augmentation: for all (u,v) in p, we just add this cf(p) to f(u,v) (and subtract it from f(v,u)) – Resulting flow is a valid flow with a larger value.
  • 12. Residual network and augmenting path
  • 13. The Ford-Fulkerson method Ford-Fulkerson(G,s,t) 1 for each edge (u,v) in G.E do 2 f(u,v)  f(v,u)  0 3 while there exists a path p from s to t in residual network Gf do 4 cf = min{cf(u,v): (u,v) is in p} 5 for each edge (u,v) in p do 6 f(u,v)  f(u,v) + cf 7 f(v,u)  -f(u,v) 8 return f The algorithms based on this method differ in how they choose p in step 3. If chosen poorly the algorithm might not terminate.
  • 14. Execution of Ford-Fulkerson (1) Left Side = Residual Graph Right Side = Augmented Flow
  • 15. Execution of Ford-Fulkerson (2) Left Side = Residual Graph Right Side = Augmented Flow
  • 16. Cuts • Does the method find the minimum flow? – Yes, if we get to the point where the residual graph has no path from s to t – A cut is a partition of V into S and T = V – S, such that s  S and t  T – The net flow (f(S,T)) through the cut is the sum of flows f(u,v), where s  S and t  T • Includes negative flows back from T to S – The capacity (c(S,T)) of the cut is the sum of capacities c(u,v), where s  S and t  T • The sum of positive capacities – Minimum cut – a cut with the smallest capacity of all cuts. |f|= f(S,T) i.e. the value of a max flow is equal to the capacity of a min cut. 8/13 8/11 5/52/4 10/15 10 6/14 13/19 3/3 s t9 a b c d Cut capacity = 24 Min Cut capacity = 21
  • 17. Max Flow / Min Cut Theorem 1. Since |f|  c(S,T) for all cuts of (S,T) then if |f| = c(S,T) then c(S,T) must be the min cut of G 2. This implies that f is a maximum flow of G 3. This implies that the residual network Gf contains no augmenting paths. • If there were augmenting paths this would contradict that we found the maximum flow of G • 1231 … and from 23 we have that the Ford Fulkerson method finds the maximum flow if the residual graph has no augmenting paths.
  • 18. Worst Case Running Time • Assuming integer flow • Each augmentation increases the value of the flow by some positive amount. • Augmentation can be done in O(E). • Total worst-case running time O(E|f*|), where f* is the max-flow found by the algorithm. • Example of worst case: Augmenting path of 1 Resulting Residual Network Resulting Residual Network
  • 19. Edmonds Karp • Take shortest path (in terms of number of edges) as an augmenting path – Edmonds-Karp algorithm – How do we find such a shortest path? – Running time O(VE2), because the number of augmentations is O(VE) – Skipping the proof here – Even better method: push-relabel, O(V2E) runtime
  • 20. Multiple Sources or Sinks • What if you have a problem with more than one source and more than one sink? • Modify the graph to create a single supersource and supersink 13 11 54 15 10 14 13 3 s t9 a b c d 13 11 54 15 10 14 13 3 x y9 e f g h 4 13 11 54 15 10 14 13 3 9 a b c d 13 11 54 15 10 14 13 3 9 e f g h 4s i j k l t    
  • 21. Application – Bipartite Matching • Example – given a community with n men and m women • Assume we have a way to determine which couples (man/woman) are compatible for marriage – E.g. (Joe, Susan) or (Fred, Susan) but not (Frank, Susan) • Problem: Maximize the number of marriages – No polygamy allowed – Can solve this problem by creating a flow network out of a bipartite graph
  • 22. Bipartite Graph • A bipartite graph is an undirected graph G=(V,E) in which V can be partitioned into two sets V1 and V2 such that (u,v)  E implies either u  V1 and v  V12 or vice versa. • That is, all edges go between the two sets V1 and V2 and not within V1 and V2.
  • 23. Model for Matching Problem • Men on leftmost set, women on rightmost set, edges if they are compatible A B C D X Y Z Men Women A B C D X Y Z A matching A B C D X Y Z Optimal matching
  • 24. Solution Using Max Flow • Add a supersouce, supersink, make each undirected edge directed with a flow of 1 A B C D X Y Z A B C D X Y Z s t Since the input is 1, flow conservation prevents multiple matchings