This document provides an overview of algorithm design and complexity, specifically focusing on flow networks. It defines key concepts related to flow networks including positive flow, net flow, flow properties, maximum flow problems, and minimum cut. It also describes the Ford-Fulkerson method and Edmonds-Karp algorithm for solving maximum flow problems using the concept of a residual network given an initial flow.
23Network FlowsAuthor Arthur M. Hobbs, Department of .docxeugeniadean34240
23
Network Flows
Author: Arthur M. Hobbs, Department of Mathematics, Texas A&M Uni-
versity.
Prerequisites: The prerequisites for this chapter are graphs and trees. See
Sections 9.1 and 10.1 of Discrete Mathematics and Its Applications.
Introduction
In this chapter we solve three very different problems.
Example 1 Joe the plumber has made an interesting offer. He says he has
lots of short pieces of varying gauges of copper pipe; they are nearly worthless
to him, but for only 1/5 of the usual cost of installing a plumbing connection
under your house, he will use a bunch of T- and Y-joints he picked up at a
distress sale and these small pipes to build the network shown in Figure 1. He
claims that it will deliver three gallons per minute at maximum flow. He has
a good reputation, so you are sure the network he builds will not leak and will
cost what he promises, but he is no mathematician. Will the network really
deliver as much water per minute as he claims?
408
Chapter 23 Network Flows 409
Figure 1. A plumber’s nightmare.
Example 2 We want to block access to the sea from inland town s on
river R. We can do this by dropping mines in the river, but because the river
spreads out in a wide delta with several outlets, the number of mines required
depends on where we drop them. The number of mines required in a channel
ranges from a high of 20 mines in R to a low of 1 in some channels, as shown
in Figure 2. In that figure, each channel is shown with a number indicating
how many mines will block it. What is the smallest number of mines needed to
block off s’s access to the sea, and where should the mines be placed?
Figure 2. Delta system of river R and numbers of mines
needed to close channels.
Example 3 At Major University, Professor Johnson is asked to hire graders
for 100 sections spread among 30 different courses. Each grader may work for
one, two, or three sections, with the upper bound being the grader’s choice,
but the number actually assigned being Professor Johnson’s choice. Professor
Johnson contacts the potential graders, learns from each both his choice of
number of sections and which courses he is competent to grade, and makes a
table showing this information, together with the number of sections of each
course being offered. Because the real problem is too large to use as an example
here, Table 1 gives a smaller example. How should the assignment of graders
be made?
In this chapter, we begin with Example 1, solve Example 2 on the way to
solving Example 1, and then solve Example 3 by using the theory developed.
Many more kinds of problems are solved using the methods of this chapter in
the book Flows in Networks by Ford and Fulkerson [4].
410 Applications of Discrete Mathematics
Course Course Course Course Max # Sec.
1 2 3 4 Wanted
Student 1 yes yes no no 3
Student 2 yes no yes yes 2
Student 3 no yes yes yes 3
# Sec. Needed 3 1 1 2
Table 1. Graders and courses.
Flow Graphs
In Example 1, we have a network of pipes th.
This is a lecture on the hydraulics of gradually varied flow in open channels. It shows the profiles common in the open channels and some numerical examples using numerical integration.
Extended network and algorithm finding maximal flows IJECEIAES
Graph is a powerful mathematical tool applied in many fields as transportation, communication, informatics, economy, in ordinary graph the weights of edges and vertexes are considered independently where the length of a path is the sum of weights of the edges and the vertexes on this path. However, in many practical problems, weights at a vertex are not the same for all paths passing this vertex, but depend on coming and leaving edges. The paper develops a model of extended network that can be applied to modelling many practical problems more exactly and effectively. The main contribution of this paper is algorithm finding maximal flows on extended networks.
Wholi: The right people find each other (at the right time)
Two key elements in this talk:
•PART 1: Machine learning for entity extraction
Natural language processing (NLP), information extraction
•PART 2: Matching profiles using deep learning classifier
Deep learning, word embeddings
Deep neural networks for matching online social networking profilesTraian Rebedea
> Proposed a large dataset for matching online social networking profiles
›This allowed us to train a deep neural network for profile matching using both domain-specific features and word embeddings generated from textual descriptions from social profiles
›Experiments showed that the NN surpassed both unsupervised and supervised models, achieving a high precision (P = 0.95) with a good recall rate (R = 0.85)
Detecting and Describing Historical Periods in a Large CorporaTraian Rebedea
Many historic periods (or events) are remembered
by slogans, expressions or words that are strongly linked to them. Educated people are also able to determine whether a particular word or expression is related to a specific period in human history. The present paper aims to establish correlations between significant historic periods (or events) and the texts written in that period. In order to achieve this, we have developed a system that automatically links words (and topics discovered using Latent Dirichlet Allocation) to periods of time in the recent history. For this analysis to be relevant and conclusive, it must be undertaken on a representative set of texts written throughout history. To this end, instead of relying on manually selected texts, the Google Books Ngram corpus has been chosen as a basis for the analysis. Although it provides only word n-gram statistics for the texts written in a given year, the resulting time series can be used to provide insights about the most important periods and events in recent history, by automatically linking them with specific keywords or even LDA topics.
Practical Machine Learning - Part 1 contains:
- Basic notations of ML (what tasks are there, what is a model, how to measure performance)
- A couple of examples of problems and solutions (taken from previous work)
- A brief presentation of open-source software used for ML (R, scikit-learn, Weka)
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
2. Overview
Flow Networks
Positive Flow and Net Flow
Flow Properties
Maximum Flow
Minimum Cut
Ford-Fulkerson Method
Edmonds-Karp Algorithm
Sample Applications
3. Flow Networks
Graphs that model materials that are transported
through conduits
Each edge represents a conduit: it has a capacity
that is an upper bound for the flow rate
Some vertices may produce materials: sources
Other vertices may consume materials: sinks
4. Flow Networks (2)
The simplest version of flow networks:
Think of edges as pipes of different sizes (capacities)
The flow is the effective quantity of liquid that is transported
through the pipes
Flow Networks are also called transportation networks
But you can transport a lot of things beside liquids, like
commodities, information, electricity, traffic
There are some interesting and difficult problems for flow
networks:
Maximum flow problem
Maximum flow with minimum cost problem
Circulation problem
Multi-commodity problem
5. Flow Networks (3)
G(V, E) – directed graph
The capacity function c: E → R+
c(u, v) = the capacity of the edge (u, v)
(u,v) E c(u,v) = 0
Assume we have a single source vertex: s
Assume we have a single sink vertex: t
Assume we have a path s .. v .. t vV
6. Positive Flow
We can define a function called positive flow
p: V x V R+
Properties of positive flow:
Capacity constraint:
u, vV: p(u, v) <= c(u, v)
Flow conservation:
uV {s, t}: flow_in(u) = flow_out(u)
uV {s, t}: vV(p(v, u)) = vV(p(u, v))
7. Positive Flow – Example
Notation on each edge: positive flow/capacity
Note that the two properties are respected
The flow is always lower than the capacity of each edge
The flow is conserved in each vertex
The source produces flow
The sink consumes flow
8. Cancellation for Positive Flow
Note that in the previous example we have:
1 unit of flow from x z
2 units of flow from z x
We can cancel 1 unit of flow in both directions
0 units of flow from x z
1 unit of flow from z x
Flow conservation is still respected (we cancel the same
amount of flow in each direction)
Capacity constraint is still respected (the flow is decreased)
In both cases, the “net flow” is 1 from z x
Without loss of generality, we may always define a
positive flow in a flow network such that for each (u, v),
u,vV, we have positive flow either from u v or from v
u, but not in both directions!
9. Net Flow
We can define a function called net flow
f: V x V R
Properties of net flow:
Capacity constraint:
u, vV: f(u, v) <= c(u, v)
Flow conservation:
uV {s, t}: total_net_flow_in(u) = 0
uV {s, t}: vV(f(u, v)) = 0
Skew symmetry:
u, vV: f(u, v) = - f(v, u)
10. Net Flow (2)
Conservation of net flow can be rewritten:
vV (f(u, v)) = 0
As f(u, v) might be either positive or negative
uV {s, t}: vV and f(u,v)<0(f(u, v)) + vV and f(u,v)>0 (f(u, v))
=0
uV {s, t}: vV and f(v,u)>0(f(v, u)) = vV and f(u,v)>0 (f(u, v))
“total positive flow entering u” = “total positive flow
leaving u”
“flow in” = “flow out”
11. Net Flow – Example
Only positive flow is illustrated in graphical
representations
Nevertheless, this does not mean that the (negative)
net flow does not exist in the other direction
12. Positive Flow and Net Flow
Differences
Net flow satisfies skew symmetry
p(u, v) >= 0, while
f(u, v) >= 0 or f(u, v) <= 0
13. Positive Flow and Net Flow (2)
Equivalence
We can define net flow using only positive flow and vice-
versa
f(u, v) = p(u, v) – p(v, u) u, vV
Need to show that using this definition, the net flow still
satisfies the three properties: capacity constraint,
conservation and skew symmetry
p(u, v) = f(u, v) if f(u, v) > 0
p(u, v) = 0 otherwise
Need to show that this definition satisfies the two
properties of positive flow: capacity constraint and
conservation
15. Value of the Flow
From now on, we shall only use net flow
Value of the flow = |f| = vV (f(s, v)) = vV (f(v, t))
In the example below: |f| = 3
16. Cancellation of (Net) Flow
Let’s say that f(u, v) = 5 and c(u, v) = 8
We can “ship” at most 3 units of flow from u v
=> f(u, v) = 8 = c(u, v)
But we can also “ship” up to 5 units of flow back from v
u
=> f(u, v) = 3 if we cancel 2 units of flow!
Called flow cancellation
If (v, u) E => f(v, u) <= c(v, u) = 0
We are not allowed to have a positive flow from v u
But we are allowed to have negative flow!
This negative flow is equal in absolute value with the
positive value from u v
17. Cancellation of (Net) Flow (2)
Due to cancellation, a flow only gives us this so-
called “net” effect. We cannot reconstruct actual
“shipments” of products from a net flow.
A flow f(u, v) = 5 and f(v, u) = -5 can mean either:
5 units u v 6 units u v 8 units u v
0 units v u 1 units v u 3 units v u
18. Flow Operations
Extend the definition of the flow to sets of vertices
X,Y V
f(X,Y) = ΣxXΣyY f(x,y) = total flow between X and Y
Possible operations:
XV f(X,X) = 0;
X,YV f(X,Y) = -f(Y,X);
X,Y,ZV si Y⊆X
f(X Y, Z) = f(X,Z) - f(Y,Z);
f(Z, X Y) = f(Z,X) - f(Z,Y);
X,Y,ZV si XY=
f(X Y, Z) = f(X,Z) + f(Y,Z);
f(Z, X Y) = f(Z,X) + f(Z,Y)
|f| = f(s,V) = f(V,t)
19. Examples (1)
X 1/2
a b
1/8 2/2
4/4 3/3
s t
3/9 Y
c d
3/5
f(X,Y) = ΣxXΣyY f(x,y)
f(X,X) = f(s,a) + f(a,s) + f(s,b) + f(b,s) + f(a,b) + f(b,a) = 0
f(X,Y) = f(b,c) + f(b,t) = -f(c,b) - f(t,b) = -f(Y,X)
Proiectarea Algoritmilor 2010
20. Examples (2)
X 1/2
a b
1/8 2/2
Y
s 4/4 3/3 t
c 3/9 Z
3/5 d
X, Y, Z V si Y ⊆ X
f(X Y, Z) = f(X, Z) - f(Y, Z)
f(Z, X Y) = f(Z, X) - f(Z, Y)
f(X Y, Z) = 0 = f(b,t) + f(c,d) - f(b,t) - f(c,d) = f(X,Z) - f(Y,Z)
f(Z, X Y) = 0 = f(t,b) + f(d,c) - f(t,b) - f(d,c) = f(Z,X) - f(Z,Y)
Proiectarea Algoritmilor 2010
21. Examples (3)
Z
X 1/2
a b
1/8 2/2
s 4/4 3/3 t
3/9 Y
c d
3/5
X, Y, Z V si X Y =
f(XY, Z) = f(X,Z) + f(Y,Z)
f(Z, XY) = f(Z,X) + f(Z,Y)
f(X Y, Z) = f(s,b) + f(a,b) + f(t,b) + f(d,c) = f(X,Z) + f(Y,Z)
f(Z, X Y) = f(b,a) + f(b,s) + f(b,t) + f(c,d) = f(Z,X) + f(Z,Y)
Proiectarea Algoritmilor 2010
22. Examples (4)
1/2
a b
1/8 2/2
4/4 3/3
s t
3/9
c d
3/5
f(s, V) = f(V, t)
f(s, V) = f(s,a) + f(s,b) = 5 = f(d,t) + f(b,t) = f(V, t)
Proiectarea Algoritmilor 2010
23. Maximum Flow Problem
Given G(V, E), c: E R+, sV and tV
Find the maximum flow that can be “transported” from s
to t
We start with an initial void flow on all edges
We want to compute the net flow between each pair of
vertices that determines a maximum flow!
Various methods are used
Only look at one of the simplest:
Ford-Fulkerson and Edmonds-Karp
Uses the notion of residual network
24. Residual Network
Given G(V, E), c: E R+, sV and tV
Knowing a given flow in the graph, f: E R
We can compute the residual capacity for any pair of
vertices:
cf(u, v) = c(u, v) – f(u, v) >= 0 (due to capacity constraint)
Residual means: how much flow we can still transport from u
v
We can compute the residual network of the graph:
It is a graph Gf = (V, Ef)
Ef = {(u, v) V x V | cf(u, v) > 0}
It is a graph that contains edges that have residual capacity
(that can still transport flow!)
How many edges does Gf have? Find the minimum and the
maximum value!
26. Augmenting Path
Any path from the residual graph admits more flow
from the start vertex to the end vertex
Therefore, we want to find a path from the source s
to the sink t in the residual graph: augmenting path
Look for p = s..t in Gf
If we can find this augmenting path, compute how
much flow we can send along it!
We are constrained by the minimum residual capacity of
any edge along the augmenting path
cf(p) = min(cf(u, v) | (u, v) is on p)
27. Augmenting Path – Example
p = <(s, w), (w, y), (y, z), (z, t)>
Is it unique? Can you find another?
28. Summing Flows
If the graph G has a flow f
And we can find another flow f’
We can sum up the two flows to find the new flow:
f(u,v) + f’(u,v)
The value of the new flow is |f| + |f’|
Therefore, if we can find an augmenting path, p, in the residual
network of a graph, we can also find another flow, fp: V x V
R
fp(u,v) = cf(p) if (u,v) is on p
fp(u,v) = -cf(p) if (v,u) is on p
fp(u,v) = 0
We can thus define a new flow in G: |f’| = |f| + |fp| > |f|
Thus, we can improve the existing flow!
29. Graph Cuts
A cut (S, T) of a flow network G(V, E) is a partitionof
the vertices into two sets S (sS) and T = V S (t
T)
Already know cuts for minimum spanning trees
The flow across the cut is f(S, T)
The capacity of the cut is c(S, T) = summing up the
capacities of all the edges starting from a vertex in S
and ending in a vertex in T
A minimum cut in G is a cut whose capacity is
minimum over all the possible cuts in G
30. Graph Cuts – Example
S = {s, w, y}, T = {x, z, t}
f(S, T) = f(w, x) + f (y, x) + f(y, z) = 2 + (-1) + 2 = 3
Includes positive flow that goes either direction across the
cut
But only takes into account net flow that goes from any
vertex in S to any vertex in T
c(S, T) = c(w, x) + c(y, z) = 2 + 3 = 5
31. Max-Flow Min-Cut Theorem
The following statements are equivalent:
f is a maximum flow in G
There is no augmenting path in Gf
|f| = c(S, T) for all minimum cuts (S, T)
This theorem gives us a method to compute the
maximum flow: push flow along augmenting paths
until you cannot find any
This theorem also tells us how to compute a
minimum cut once the maximum flow is known
When f is a maximum flow, all the vertices reachable from
s in Gf are in S, the others are in T => (S, T) is a minimum
cut
32. Ford-Fulkerson Method
1. Start with a void flow
2. Compute the residual graph for the given flow
3. If there is an augmenting path in this residual graph
a) Increase the flow along it
b) Go to step 2
4. The maximum flow has been reached!
The disadvantage of this method is that it does not
specify how to look for the augmenting path in step 3
Any method can be used
Pick a random augmenting path
Use any search algorithms to compute the path: DFS, BFS
Be greedy: look for the fattest pipe each time! How?
33. Ford-Fulkerson Method (2)
If the augmenting path is not picked smartly, then the
worst case running time for the algorithm is O(E*|fmax|)
Why?
Each augmenting path has at most O(E) edges that will
cause a change in the value of the flow along them at
each step!
Maximum number of steps is fmax if a each step cf(p)=1
See the example on the next slides!
It is not good that the running time depends on fmax
What happens if the capacities of the edges are irrational
number? => so is fmax
34. Exemplu Ford – Fulkerson (1)
1000 B 1000
0/1000 B 0/1000
1
G
0/1 Gf A D
A D
1000 C 1000
0/1000 C 0/1000
Residual Path: A-B-C-D; Cf = 1
1
1/1000 B 0/1000 B 1000
999 G
1/1 Gf A 1 D
A D 999
0/1000 C 1/1000 1000 C 1
Residual Path : A-B-C-D; Cf = 1
1/1000 B 1/1000 1 B 999 1
Gf 999 G
A 0/1 D A 1 D
999
1/1000 C 1/1000 999 C 1
1
Proiectarea Algoritmilor 2010
Residual Path : A-B-C-D; Cf = 1
35. Exemplu Ford – Fulkerson (2)
2
2/1000 B 1/1000 B 999 1
998 G
1/1 Gf 1
A D A D
998
999 C
1/1000 C 2/1000 1 2
… Residual Path: A-C-B-D; Cf = 1
1000/1000 B 1000/1000 B
1000 1000
0/1
Gf
A D A 1 D
1000/1000 C 1000/1000 1000 C 1000
Residual Path: Ø
How many steps are needed to reach the maximum flow?
Proiectarea Algoritmilor 2010
36. Edmonds-Karp Algorithm
Is a variant of the Ford-Fulkerson algorithm that
guarantees to have a running time that is
independent of fmax
Always picks the augmenting path using BFS on Gf
Source vertex for BFS is s
You may stop when t is reached
This way, the length of the augmenting paths is
increasing when running the algorithm
We always pick an augmenting path with an equal or
greater length than the previous one
37. Edmonds-Karp Algorithm (2)
Edmonds–Karp(G, s, t)
FOREACH (u,v) in E
f(u,v) = f(v,u) = 0 // O(E)
WHILE (1) // O(E*V)
p = find-augmenting-path-using-bfs(G, f, s, t) // O(E)
IF (p == null)
BREAK
cf(p) = min{cf(u,v) | (u,v) in p} // O(E)
FOREACH (u,v) in p // O(E)
f(u,v) = f(u,v) + cf(p)
f(v,u) = -f(u,v)
RETURN f
Complexity: O(V*E2)
38. Edmonds-Karp – Example
1000 B 1000
0/1000 B 0/1000
1
G
0/1 Gf A D
A D
1000 C 1000
0/1000 C 0/1000
Residual Path: A-B-D; Cf = 1000
1000/1000 B 1000/1000 1000 B
1000
0/1 Gf 1
G
A D A D
0/1000 C 1/1000 1000 C 1000
Residual Path: A-C-D; Cf = 1000
1000/1000 B 1000/1000
1000 B
1000
0/1 Gf
A D 1
A D
1000/1000 C 1000/1000 1000 1000
C
Proiectarea Algoritmilor 2010
Residual Path: Ø
39. Application: Maximum Bipartite Matching
Bipartite graph: we can partition the graph into two sets
of vertices L, R such as L U R = V and for all (u, v)E,
uL, vR
Matching: a subset of edges, M, such that for all vV at
most an edge in M is incident in v
Need to transform this problem into a maximum flow
40. Application: The Escape Problem
http://webcourse.cs.technion.ac.il/234247/Spring2006/ho/
WCFiles/The%20Escape%20Problem.pdf
41. Conclusions
Flow networks are met very often in real life
A lot of applications and interesting problems to be solved:
maximum flow is only one of them
It is important to know the main concepts of flow networks:
positive flow, net flow, cuts, augmenting networks, etc.
Ford-Fulkerson gives us a generic method to compute the
maximum flow in a graph
Edmonds-Karp is a variant of FF that runs in O(V*E2)
There are other algorithms that work better
A lot of problems can be solved using maximum flow, but you
need to be able to “transform” them into a flow problem!