• Nem Talált Eredményt

Network Flows

N/A
N/A
Protected

Academic year: 2022

Ossza meg "Network Flows"

Copied!
34
0
0

Teljes szövegt

(1)

Network Flows

László Papp

BME

9th of May, 2022

(2)

Task

We want to transport the oil produced in Siberia to Central Europe. We have several pipelines to do that, but each of them has a capacity limitation. We assume that there is no leak on the pipeline system, so we receive exactly the same amount of oil as much have been inserted to the system in Russia.

(3)

Task

We want to transport the oil produced in Siberia to Central Europe. We have several pipelines to do that, but each of them has a capacity limitation. We assume that there is no leak on the pipeline system, so we receive exactly the same amount of oil as much have been inserted to the system in Russia.

We know the capacity of each pipeline segment.

Questions:

I What is the maximum amount of oil which can be transported from Siberia to Central Europe?

I How can we do it?

(4)

Mathematical model: Network

I A directed graphG~ is given, which tells the directions and the connections of the pipeline segments.

I There are two distinguished verticessandtwhich are the source and the target, respectively.

I A capacity functionc :E(G)~ →R+ is given.

Definition:The quadruple(G,~ s,t,c)is called as a network.

B A

C

S T

D (12)

(10) (5)

(5) (10)

(13)

(20)

(3) (9)

A graphical representation of a network, the numbers in brackets are the capacities.

(5)

Flow

Letf be a non negative function which associates each edge to a non-negative real number.

Notation:Letv be a vertex ofG~ and we denote the the directed edge(u,~v)with the short formuv~ .

I INf(v) =P

u:uv∈E(~ G)~ f(uv~ ) I OUTf(v) =P

w:vw∈E(~ G)~ f(vw~ ) Example:

INf(v) =

12+5+10=27 OUTf(v) = 20+9=29

A

C B

E D

10 5

12 20

9 v

(6)

Flow

Definition:A non negative functionf :E(G)~ →R+∪0 is a flowif:

1. For every edgeeofG:~ f(e)≤c(e). (Capacity constraint) 2. For each vertexv ofG~ which is neithersnort:

INf(v) =OUTf(v)so:

X

u:uv∈E(~ G)~

f(uv~ ) = X

w:vw∈E(~ G)~

f(vw).~

(Conservation law of flows)

So at each vertex except the source and the target the value of the in flow and the out flow is the same.

B A

C S

7 (10) 12 (20)

3 (3) 12 (12)

3 (10) 5 (5)

0 (5)

0 (9) T

D 8 (13)

(7)

Objective function

Definition:Thevalueof flowf is mf =INf(t)−OUTf(t) = X

v:vt~∈E(G)~

f(vt)~ − X

v:tv∈E(~ G)~

f(tv~).

Claim

mf =OUTf(s)−INf(s) =INf(t)−OUTf(t). So the source produces exactly the same as the target consumes.

Task: Find a maximum flow (a flow whose value is maximum)!

Problem: Why does such a flow exists? Why it does not happen, that for any >0 there is a flowfsuch that mf >c−, but no flow of valuec exists.

It can be proven by the tools of analysis (squeeze lemma, a bounded sequence has a convergent subsequence, etc.) that in any flow network, there is always a maximum flow.

(8)

Objective function

Definition:Thevalueof flowf is mf =INf(t)−OUTf(t) = X

v:vt~∈E(G)~

f(vt)~ − X

v:tv∈E(~ G)~

f(tv~).

Claim

mf =OUTf(s)−INf(s) =INf(t)−OUTf(t). So the source produces exactly the same as the target consumes.

Task: Find a maximum flow (a flow whose value is maximum)!

Problem: Why does such a flow exists? Why it does not happen, that for any >0 there is a flowfsuch that mf >c−, but no flow of valuec exists.

It can be proven by the tools of analysis (squeeze lemma, a bounded sequence has a convergent subsequence, etc.) that in any flow network, there is always a maximum flow.

(9)

Objective function

Definition:Thevalueof flowf is mf =INf(t)−OUTf(t) = X

v:vt~∈E(G)~

f(vt)~ − X

v:tv∈E(~ G)~

f(tv~).

Claim

mf =OUTf(s)−INf(s) =INf(t)−OUTf(t). So the source produces exactly the same as the target consumes.

Task: Find a maximum flow (a flow whose value is maximum)!

Problem: Why does such a flow exists? Why it does not happen, that for any >0 there is a flowfsuch that mf >c−, but no flow of valuec exists.

It can be proven by the tools of analysis (squeeze lemma, a bounded sequence has a convergent subsequence, etc.) that in any flow network, there is always a maximum flow.

(10)

s-t cuts

Definition:LetX ⊆V(G)~ such thats ∈X butt∈/ X. Ans-t cut CX is the set of edges, which connect vertices contained inX to the vertices which are not contained inX. More formally:

CX ={uv|~ uv~ ∈E(G),~ u∈X,v ∈/X orv ∈X,u∈/ X}.

The capacity of thes−t cutCX is the total capacity of its edges whose tail is inX. Soc(CX) =P

uv:~ uv∈C~ X,u∈Xc(uv~ ).

Example:

B A

C

S T

(10) D (5)

(5) (10)

(13)

(20)

(3) (9)

X

C (12)

c(CX) =12+10=22

(11)

Inspecting the flow value on an s-t cut

Claim

IfCX is an arbitrarys−t cut, then the value of the flow is

mf = X

~ xz:x∈X

~ xz∈CX

f(xz~ )− X

~ zx:x∈X

~ zx∈CX

f(zx~ )

B A

C

S T

D

2 (3) 10 (10)

3 (5) 13 (13)

12 (12)

17 (20)

5 (9) 3 (5) 6 (10)

Y

D A B

C

S T

X D

C

2 (3) 10 (10)

3 (5) 13 (13)

12 (12)

17 (20)

5 (9) 3 (5) 6 (10)

(12)

Proof:

We show that if we add one more vertex to a cut, then P

~ xz:x∈X

~ xz∈C

f(xz)~ −P

~ zx:x∈X

~ zx∈C

f(zx~ )does not change. We add vertices one by one toX until everything is inX exceptt. That s−t cut defines the flow value. LetX =Y ∪ {v}.

B A

C

S T

D 2 (3) 10 (10)

3 (5) 13 (13)

12 (12)

17 (20)

5 (9) 3 (5) 6 (10)

Y

D

B A

C

S T

X D

C

2 (3) 10 (10)

3 (5) 13 (13)

12 (12)

17 (20)

5 (9) 3 (5) 6 (10)

X

xz:x∈X~

~ xz∈CX

f(xz~ )− X

zx:x∈X~

~ zx∈CX

f(zx) =~

= X

xz:x∈Y~ xz∈C~ Y

f(xz~ )− X

zx:x∈Y~ zx∈C~ Y

f(zx~ ) + X

z:vz∈E(~ G)~

f(vz~ )− X

z:zv∈E(~ G)~

f(zv~ )

| {z }

=OUTf(v)−INf(v)=0 (conservation law)

(13)

Benefits of thes−tcuts

Corollary:The source produces exactly the same as the target consumes.

Claim

The value of a flow in a network is at most the capacity of any s−t cut.

Proof:LetCX be ans−t cut. Using the previous claim:

mf = X

xz:x∈X~

~ xz∈CX

f(xz~ )− X

zx:x∈X~

~ zx∈CX

f(zx~ )≤ X

xz:x∈X~

~ xz∈CX

f(xz)~ ≤

≤ X

xz:x∈X~ xz∈C~ X

c(xz~ ) =c(CX)

(14)

Ford-Fulkerson (Max Flow Min Cut) Theorem Theorem

In any flow network the value of the maximum flow equals to the minimum capacity over alls−t cuts.

Question: Why is this theorem useful?

If we find a flow of valuek and ans−tcut of capacityk, then we can be 100 percent sure, that the flow is maximum and the cut is a minimum.

B A

C S

9 (10) 19 (20)

3 (3) 12 (12)

10 (10) 3 (5)

0 (5)

7 (9) T

D 13 (13)

(15)

Ford-Fulkerson (Max Flow Min Cut) Theorem Theorem

In any flow network the value of the maximum flow equals to the minimum capacity over alls−t cuts.

Question: Why is this theorem useful?

If we find a flow of valuek and ans−t cut of capacityk, then we can be 100 percent sure, that the flow is maximum and the cut is a minimum.

B A

C S

9 (10) 19 (20)

3 (3) 12 (12)

10 (10) 3 (5)

0 (5)

7 (9) T

D 13 (13)

(16)

How to find a maximum flow?

Start from a flow and improve it!

How to find a flow initially? The trivial∀e∈E(G)~ f(e) =0 function is always a flow.

B A

C S

0 (13)

0 (10) 0 (20)

0 (3) 0 (12)

0 (10) 0 (5)

0 (5)

0 (9) T

D

(17)

Augmenting paths

Definition:An edgeeissaturatediff(e) =c(e). If an edge is not saturated, then we say that it isunsaturated.

B A

C S

7 (10) 12 (20)

3 (3) 12 (12)

3 (10) 5 (5)

0 (5)

0 (9) T

D 8 (13)

If there is a directed pathP~ fromstot containing only

unsaturated edges, then we can increase the flow value among

~Pbymine∈E(P)~ (c(e)−f(e)).

In the example the flow value have been increased by 5.

(18)

Augmenting paths

Definition:An edgeeissaturatediff(e) =c(e). If an edge is not saturated, then we say that it isunsaturated.

B A

C S

7 (10) 17 (20)

3 (3) 12 (12)

5 (5) 0 (5)

T

8 (10) D

5 (9) 13 (13)

If there is a directed pathP~ fromstot containing only

unsaturated edges, then we can increase the flow value among

~Pbymine∈E(P)~ (c(e)−f(e)).

In the example the flow value have been increased by 5.

(19)

Other kind of improvement

Sometimes we need to decrease the flow on an edge to increase the value of the flow:

B A

C S

7 (10) 17 (20)

3 (3) 12 (12)

8 (10) 5 (5)

0 (5)

5 (9) T

D 13 (13)

If we increase the flow by 2 on the blue edges and decrease it by 2 on the red edge, then we obtain a flow whose value is more by 2.

(20)

Other kind of improvement

Sometimes we need to decrease the flow on an edge to increase the value of the flow:

B A

C S

3 (3) 12 (12)

0 (5)

T

D 13 (13)

10 (10) 3 (5) 9 (10)

7 (9) 19 (20)

If we increase the flow by 2 on the blue edges and decrease it by 2 on the red edge, then we obtain a flow whose value is more by 2.

(21)

Ford-Fulkerson Algorithm: The residual graph

We create a residual graphSf for the(G,~ s,t,c)network and flowf. Each edge ofSf is going to have a corresponding value called as the width.

1. The vertices ofSf are the vertices ofG~ andSf does not have an edge in the beginning.

2. For each edgeuv~ ofG~ we do the following:

2.1 Ifuv~ is unsaturated, then we add theuv~ forward edge toSf with widthc(uv)~ f(uv~ ).

2.2 Ifuv~ >0, then we add thevu~ backward edge toSf with widthf(uv).~

B A

C S

7 (10) 12 (20)

3 (3) 12 (12)

3 (10) 5 (5)

0 (5)

0 (9) T

D 8 (13)

B A

C S

12

5

T

D 3

7

7 5

8

3 5

9 8

3 12

(22)

Ford-Fulkerson Algortihm

0. Start with a flowf, (which is given or the trivial).

1. Create the residual graphSf.

2. Search for a directed path fromstot inSf.

3. If there is no such directed path, then STOP, otherwise let P~ be such a path and let∆be the width of~P, so the smallest width value of its edges.

4. Do for eachuv~ directed edge ofP:~

4.1 Ifuv~ is a forward edge ofSf, then increase the flow on edge uv~ by∆.

4.2 Ifuv~ is a backward edge, then decrease the flow on edge vu~ by∆.

5. Continue with step 1.

(23)

Example (starting from a nontrivial flow) B

A

C S

7 (10) 12 (20)

3 (3) 12 (12)

3 (10) 5 (5)

0 (5)

0 (9) T

D 8 (13)

B A

C S

12

5

T

D 3

7

7 5

8

3 5

9 8

3 12

(24)

Example (starting from a nontrivial flow) B

A

C S

7 (10) 17 (20)

3 (3) 12 (12)

8 (10) 5 (5)

0 (5)

5 (9) T

D 13 (13)

B A

C S

12

5

T

D 3

7

2 8 5

3

3 17 13

4 5

(25)

Example (starting from a nontrivial flow) B

A

C S

9 (10) 19 (20)

3 (3) 12 (12)

10 (10) 3 (5)

0 (5)

7 (9) T

D 13 (13)

B A

C S

12

T

D 1

5

1

3 19 13

2 7

10 3

9

2

(26)

Minimum s-t cut

B A

C S

9 (10) 19 (20)

3 (3) 12 (12)

10 (10) 3 (5)

0 (5)

7 (9) T

D 13 (13)

The capacity of the cut is 22, so there is no

bigger flow.

(27)

Why is this algorithm correct?

Claim

If there is no directed path fromstot in the residual graphSf, thenf is a maximum flow.

In this case letX be the set of vertices which can be reached fromsby a directed path inSf. The cutCX is a minimum cut.

Proof:There are no backward edges fromX toV(G)\X, so all the edges whose tails and heads are contained inV(G)\X andX, respectively, have zero flow value. Similarly, there is no forward edge fromX toV(G)\X inSf, thus all of these edges are saturated inG. Furthermore the value of the flow is the sum~ of the flow of these edges which equals to the sum of their capacities, which isc(Cx). So the value of the flow equals to the value of ans−tcut, so it is a maximum flow andCx is a minimums−tcut.

Remark: This proves the Ford-Fulkerson Theorem if the algorithm always terminates.

(28)

Running time? Does this algorithm halt?

Edmonds-Karp Theorem

If at the residual graph we choose the shortest (containing the least number of edges) directed path fromstot, then the running time is polynomial (O(ne2)).

If we do not follow this rule and chose the directed paths randomly then the algorithm can run for so long. If the

capacities are not rational numbers, then it is also possible that the algorithm never halts.

A

C

S T

(10000) (10000) (10000)

(10000) (1)

Recommendation:Always chose a shortest directed path fromstot when we run the Ford-Fulkerson algorithm!

(29)

Flow Integrality Theorem Claim

If each capacity is an integer in the flow network, then there is a maximum flowf which satisfies that the flow on each edge is integer.

B A

C S

7 (10) 17 (20)

3 (3) 12 (12)

5 (5) 0 (5)

T

8 (10) D

5 (9) 13 (13)

Proof:We start from the trivial flow and run the Ford-Fulkerson algorithm. Since it changes the flow on each edge by an integer number at each step it find a maximum flow which has the desired properties.

(30)

Multiple sources and targets

Oil is produced and consumed at several places. In the electricity network there are many power plants and many consumers.

How to handle them by these techniques?

(31)

Multiple sources and targets

Lets1,s2, . . . ,snandt1,t2, . . . ,tmbe the set of sources and targets, respectively. LetG~ be a directed graph which tells us the connections and letc be a non-negative capacity function.

B A

C D

s2

s3 t2

(12)

(3) (3)

(3) (9) (5)

(20)

(5)

t1

(10) (∞)

(∞) (∞)

(13)

(∞) (∞) s1 (10)

We create a super sourceSand a super targetT-t. For eachsi we add a directed edge of capacity∞whose head issi and tail isS. Similarly, for eachti we add a directed edge of capacity∞ whose tail isti and head isT. We have traced back the problem to a network flow problem where there is only one sourceSand one targetT.

(32)

Multiple sources and targets

Lets1,s2, . . . ,snandt1,t2, . . . ,tmbe the set of sources and targets, respectively. LetG~ be a directed graph which tells us the connections and letc be a non-negative capacity function.

B A

C D

S T

s1

s2

s3 t2

(∞) (∞)

(∞) (∞) (∞)

(10) (12)

(3) (3)

(3) (9) (5)

(20)

(5)

t1

(13) (10)

We create a super sourceSand a super targetT-t. For eachsi we add a directed edge of capacity∞whose head issi and tail isS. Similarly, for eachti we add a directed edge of capacity∞ whose tail isti and head isT. We have traced back the problem to a network flow problem where there is only one sourceSand one targetT.

(33)

Vertex capacities

Usually in a network, the junctions also have some limiting factors.

How to handle these cases?

(34)

Vertex capacities

Let(G,~ s,t,c)a usual network and letk :V(G)~ →R+be a capacity function over the vertices ofG~ and we are searching for flows which satisfies that for each vertexv INf(v)≤k(v).

A

C B

E D

(10)

(12) (20)

(9) (5)

A

C B

E D

(10)

(12) (20)

(5)

(9) (k(v))

v

vin vout

We split each vertexv to two vertices: vin andvout. We place the directed edgevin~vout and we set its capacity tok(v). We replace the directed edgesuv~ andvu~ by directed edgesuv~in andvout~ u, respectively.

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

Furthermore, when an MPLS network supports DiffServ, traffic flows can receive class- based admission, differentiated queue servicing in the network nodes, preemption priority,

In the current paper a numerical approach for the calculation of one dimensional unsteady blood flow in the arterial network is presented.. The continuity and momentum equations

The de- signed MPC based tra ffi c control strategy proves e ff ectiveness by creating optimal flow in the network subjected to control in- put

In this paper it has been shown that the higher-order semirelative sensitivity functions of an open circuit voltage transfer function can always be calculated by the

The main focus of the egocentric network analysis was the exploration of the social embeddedness of Roma undergraduates in the process of college transition: that is, whom can

Fleiner [13] established that a stable flow always exists by reducing it to the stable allocation problem.We present an augmenting path algorithm for computing a stable

CONCLUSION AND OUTLOOK The presented convolutional neural network was successful in learning abstractions from velocity fields by being able to predict the stagnating flow in a

The flow rate was 7 / 4 of the base case, that value was justified by the coil temperature reduction and the fact, that there was no any additional hole in the stator just the