• Keine Ergebnisse gefunden

Network Flows

N/A
N/A
Protected

Academic year: 2022

Aktie "Network Flows"

Copied!
81
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Network Flows

(and why you should like them)

(2)

Outline

• Flow networks

• Maximum flow

• Ford-Fulkerson

• Push-Relabel

• How does this link to ML2

• Parametric Max-flow

(3)

Flow Networks

• A flow network G = (V, E) is a directed graph.

• Each edge (u,v) ∈ E has a nonnegative capacity c(u,v) ≥ 0.

• Two special vertices exist: a source s and a sink t.

• If (u,v) ∉ E, we assume that c(u,v) = 0.

• For our convenience let’s say that G is connected.

(4)

Flow

• A flow in G is a real-valued function f : V × V → R which satisfies:

• Capacity constraint: ∀u,v ∈ V : f (u,v) ≤ c(u,v).

• Skew symmetry: ∀u,v ∈ V : f (u,v) = −f (v,u).

• Flow conservation: ∀u ∈ V \{s,t } : ∑

v∈V

f (u,v)=0.

(5)

Examples: Network + Flow

• What’s the flow value |f|?

• How can flow be augmented?

• How can we know if flow is a maximal flow?

(6)

The Residual Network

Flow edges (u,v) are weighted with their residual capacity c(v, u) − f (v, u).

Reverse flow edges (v,u) are inserted and also set to the residual capacity c(v, u)−f (v, u). This can lead to values bigger then c(v, u).

Edges with zero weight are usually not drawn in our examples.

(7)

Augmenting Path

An augmenting path p is a simple path from s to t in the residual network.

The residual capacity, this is the amount our flow can be augmented along the augmenting path, is given by 


c

f

(p) = min {c

f

(u,v) : (u,v) is on p}.

In our example this value is 4!

(8)

Augmenting Path

• The found c f (p) can now be added to each arrow in 
 s−t-direction and subtracted from the others.

Flow Update

(9)

Maximal Flow 


no augmenting path from s to t

• The final flow is |f | = ∑ v∈V f (u,t ) = ∑ v∈V f (s,v ).

(10)

Max-Flow Min-Cut Theorem

• but, wait… 


let’s get the cut-thing straightened out first!

(11)

Graph Cut?

• A cut C=(S, T ) is a partition of V of a Graph G=(V,E )

• An s-t cut C=(S,T ) of G is a cut of G such that s∈S and t ∈T.

• The cut-edges of a cut C are the set: 


{ (u,v)∈E | u ∈S, v ∈T }

• If edges have weights, the cost of a cut can easily

be determined by summing the cost of all cut-edges.

(12)

Max-Flow Min-Cut Theorem

• It proves the equivalence of the following

conditions in a flow network G = (V,E) with source s and sink t :

f is a maximum flow in G.

• The residual network G f contains no augmenting paths.

• |f | = c(S,T ), for some cut (S,T ) of G. 


(With s ∈ S ; t ∈ T !)

(13)

What’s next?

• We know what it is, but…

• …we cannot find it yet!

(14)

Max-Flow Algorithms

(15)

Max-Flow Algorithms Maximum Flow overview

method algorithm runtime

Ford-Fulkerson naive

Ford-Fulkerson Edmonds-Karp push-relabel naive

push-relabel relabel-to-front push-relabel + dynamic trees

O (E | f ? | )

(16)

The Ford-Fulkerson Algorithm

(17)

The Ford-Fulkerson Algorithm

(18)

The Ford-Fulkerson Algorithm

• Can you think of a bad instance?

(19)

The Ford-Fulkerson Algorithm

• Ford-Fulkerson takes O(Eᐧf

max

).

• Edmonds-Karp can do it in O(VᐧE 2 ).

• They avoid the problem of the ‘bad instance’ by changing their search for the augmenting path from DFS style to

adequately formulated shortest path search.

(20)

Push Relabel

• Soften our definition of a flow to something called a pre-flow:

• Capacity constraint: ∀u,v ∈ V : f (u,v) ≤ c(u,v).

• Skew symmetry: ∀u,v ∈ V : f (u,v) = −f (v,u).

• Flow conservation: ∀u ∈ V \{s,t } : ∑

v∈V

f (u,v) = 0.

(21)

The Push-Relabel Algorithm

push-relabel algorithms

Maximum Flow

• Define preflow

• Define height function

• Preflow with height function has no augmenting path Flow with height function is a maximum flow

8 u, v 2 V : f (u, v )  c(u, v) 8 u, v 2 V : f (u, v ) = f (v, u) 8 u 2 V { s, t } : P

v 2 V f (u, v )  0

h(s) = | V | , h(t) = 0

h(u)  h(v ) + 1 if c(u, v ) f (u, v) 0

(22)

The Push-Relabel Algorithm

push-relabel by example

Maximum Flow

0 9

s t

12 0

14 0

4 10 7 0

20 0

13 0

160

4 0

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 :

h(u)  h(v ) + 1

(23)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

13

16 10

4 9 7 4

14

20 12

s t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

push-relabel by example

(24)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

10 4 9 7 4

14

20 12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

push-relabel by example

(25)

The Push-Relabel Algorithm

7 4

Maximum Flow

0 1 2 3 4 5 6 7 8

10 4 9

14

20 12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

16 13

push-relabel by example

(26)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

10 9

7 4

20 12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

16

13

14 4

push-relabel by example

(27)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

10 9

7 4

20 12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

16 13

1 4

13

push-relabel by example

(28)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

10 9 7 4

20 12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

16

13

1 4

13

push-relabel by example

(29)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

10 9 7 4

20 12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

16 7

1 4

13

4 2

push-relabel by example

(30)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

10 9

20 12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

16 7

13 1

4 2

7 4 4

push-relabel by example

(31)

The Push-Relabel Algorithm

20

Maximum Flow

0 1 2 3 4 5 6 7 8

10 9

12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

16 7

11 3

4

2 7 4

4

push-relabel by example

(32)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

10

9 t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

16

7

11 3

4

2 7 4

4

12

20

push-relabel by example

(33)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

10

9 t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

4

19

11 3

4

2 7 4

4

12

20

push-relabel by example

(34)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

10

9 t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

4

19

11 3

4

2 7 4

4

12

20

push-relabel by example

(35)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

6

9 t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

19

11 3

4

6 7 4

8

12

20

push-relabel by example

(36)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

6

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16

13

s

✓ ✓

19

11 3

4 6

7 4 8

12

20 9

push-relabel by example

(37)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16

13

s

✓ ✓

19

11 3

4 6

7 4 2

12

20 9

push-relabel by example

(38)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16

13

s

✓ ✓

19

11 3

4 6

4 7

2

12

20 9

push-relabel by example

(39)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

12

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16

13

s

✓ ✓

11 3

23 6

4 7

2

12 1

9

19

push-relabel by example

(40)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

11 3

23 6

4 7

2

1 9

19 12

12

push-relabel by example

(41)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

11 3

23 6

4 7

8

1 9

19 6

12

push-relabel by example

(42)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

14

23 3

4 7

8

1 9

19 6

12 3

push-relabel by example

(43)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16

s 13

✓ ✓

14

23 3

4 7

8

1 9

19 6

12 3

push-relabel by example

(44)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16

s 13

✓ ✓

14

23 3

4 7

5

1 9

19 9

12 3

push-relabel by example

(45)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

14

23 3

4 7

5

1 9

19 9

12

3

push-relabel by example

(46)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

14

23 3

4 7

5

1 9

19 9

12

3

push-relabel by example

(47)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

14

23 3

4 7

8

1 9

19 6

12

3

push-relabel by example

(48)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

14

23 3

7 4 8

1 9

19 6

12

3

push-relabel by example

(49)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16 13

s

✓ ✓

11 ✓

23 6

7 4 8

1 9

19 6

12

3

push-relabel by example

(50)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16

13

s

✓ ✓

11 ✓

23 6

7 4 8

1 9

19 6

12

3

push-relabel by example

(51)

The Push-Relabel Algorithm Maximum Flow

0 1 2 3 4 5 6 7 8

t

h(s) = | V | , h(t) = 0,

if c(u, v) f (u, v) 0 : h(u)  h(v ) + 1

16

7

s

✓ ✓

11 ✓

23 7 4

8

1 9

19 6

12

3 6

• no overflowing regular flow

• height function maximum flow!

push-relabel by example

(52)

The Push-Relabel Algorithm

relabel-to-front algorithm

Maximum Flow

• Push-relabel algorithm has runtime

Better than Ford-Fulkerson method!

• The order in which we “push” and “relabel” is arbitrary

• We can do better if we choose a good order

• Relabel-to-front achieves runtime with “dynamic trees” even

O (V 2 E )

O (V 3 )

(53)

Max-Flow Algorithms Maximum Flow overview

method algorithm runtime

Ford-Fulkerson naive

Ford-Fulkerson Edmonds-Karp push-relabel naive

push-relabel relabel-to-front push-relabel + dynamic trees

O (E | f ? | )

(54)

Network Flows

(and why you should like them)

(55)

How does this link to ML2

(56)

How does this link to ML2

unary costs

ising & edge costs

(57)

How does this link to ML2

unary costs

ising & edge costs

(58)

How does this link to ML2

• Binary submodular problem → ‘graph cut’!

• K-ary submod. problem → ‘binarize’ → graph cut!

• Metric k-ary problem → α-Expansion → needs gc!

• Semimetric k-ary problem → αβ-Swap → needs gc!

(59)

Network Flows

(and why you should like them)

(60)

Parametric Max-Flow

(61)

Parametric Max-Flow

• Why parametric?

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

(62)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

Goal: constructing a complete list (x1

,I

1

),…,(x

k

,I

k

) 


such that solutions x

i

is optimal for interval λ∈I

i

and


sup I

i

⩽ I

j

for adjacent intervals in the list.

(63)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

Goal: constructing a complete list (x1

,I

1

),…,(x

k

,I

k

) 


such that solutions x

i

is optimal for interval λ∈I

i

and


sup I

i

⩽ I

j

for adjacent intervals in the list.

(64)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

Goal: constructing a complete list (x1

,I

1

),…,(x

k

,I

k

) 


such that solutions x

i

is optimal for interval λ∈I

i

and


sup I

i

⩽ I

j

for adjacent intervals in the list.

(65)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

Goal: constructing a complete list (x1

,I

1

),…,(x

k

,I

k

) 


such that solutions x

i

is optimal for interval λ∈I

i

and


sup I

i

⩽ I

j

for adjacent intervals in the list.

(66)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

Goal: constructing a complete list (x1

,I

1

),…,(x

k

,I

k

) 


such that solutions x

i

is optimal for interval λ∈I

i

and


sup I

i

⩽ I

j

for adjacent intervals in the list.

(67)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

Goal: constructing a complete list (x1

,I

1

),…,(x

k

,I

k

) 


such that solutions x

i

is optimal for interval λ∈I

i

and


sup I

i

⩽ I

j

for adjacent intervals in the list.

(68)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

Goal: constructing a complete list (x1

,I

1

),…,(x

k

,I

k

) 


such that solutions x

i

is optimal for interval λ∈I

i

and


sup I

i

⩽ I

j

for adjacent intervals in the list.

(69)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

Goal: constructing a complete list (x1

,I

1

),…,(x

k

,I

k

) 


such that solutions x

i

is optimal for interval λ∈I

i

and


sup I

i

⩽ I

j

for adjacent intervals in the list.

(70)

Parametric Max-Flow

What we just did is known as the ES-method

[Eisner and Severence, 1976]

Goal: maintaining a list (x1,I1),…,(xk,Ik) such
 that solutions xi is optimal for interval λ∈Ii and
 sup Ii ⩽ Ij for adjacent intervals in the list.

(71)

Parametric Max-Flow

Goal: maintaining a list (x1,I1),…,(xk,Ik) such
 that solutions xi is optimal for interval λ∈Ii and
 sup Ii ⩽ Ij for adjacent intervals in the list.

Runtime?!

We have to minimize the energy
 potentially for all possible break-
 points B. (Number of call to max-
 flow is in fact bounded by 2B+2.) A proof exists that |B| can be 


exponential in the size of the 
 problem. Not so cool!

…but…

What we just did is known as the ES-method

[Eisner and Severence, 1976]

(72)

Parametric Max-Flow

• The monotone case is simpler!

• Monotone??? → All b u are positive (or all negative).

(73)

Parametric Max-Flow

• Linear many max-flow operations are enough.

(Not exponentially many any more!)

• Max-flow can be “warm-started” by reusing the

previous residual flow network!

(74)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

λ 1

λ 2

(75)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

• Fix bright part to label ‘1’.

• Fix green part to label ‘0’.

• Compute max-flow only on the violet areas.


This gives you an intermediate result at λ.

(76)

Parametric Max-Flow

Kolmogorov, V., Boykov, Y., & Rother, C.; (ICCV 2007);


Applications of parametric maxflow in computer vision.

• Fix bright part to label ‘1’.

• Fix green part to label ‘0’.

• Compute max-flow only on the violet areas.


This gives you an intermediate result at λ.

λ

(77)

Parametric Max-Flow

• Some more examples (playing with priors):

(78)

Parametric Max-Flow

• Tests on Ising Prior (k 2 )

k1 = 1, k2 = 0.01, k3 = 0

9389 cuts 6058 cuts k1 = 1, k2 = 0.1, k3 = 0

k1 = 1, k2 = 1, k3 = 0

2027 cuts 2104 cuts k1 = 1, k2 = 10, k3 = 0

(79)

Parametric Max-Flow

• Tests on Edge Prior (k 3 )

k1 = 1, k2 = 0, k3 = 10

4515 cuts

18833 cuts

k1 = 1, k2 = 0, k3 = 1 k1 = 1, k2 = 0, k3 = 0.1

18833 cuts

k1 = 1, k2 = 0, k3 = 100

469 cuts

(80)

Parametric Max-Flow

(81)

Parametric Max-Flow

Referenzen

ÄHNLICHE DOKUMENTE

characterise …rst and …nal contagion thresholds (i.e., the value of the smallest shock capable of inducing default contagion and the value of the smallest shock capable of inducing

In this demo, we present FlowEmu, an open- source flow-based network emulator that allows the user to manipulate the under- lying model and analyze various statistics in real-time

For the gathered packets and events, we have monitored two relevant performance metrics, which are the number of processed packets inside each window and the required time to

Definition: A single source – single sink network is a connected digraph that has a distinguished vertex called the source with nonzero outdegree and a distinguished vertex called

If there is a u-v separating set that contains a vertex adjacent to both vertices u and v, then Assertion 5.3.4a guarantees the existence of k internally disjoint u-v paths in G..

A Media Flow is a normal Flow of media packets. There are no mandatory fields, as these Flows may also be exported by standard IPFIX devices not extended for SIP related monitoring

We have examined the community structure of industries, finding groups corresponding to food, chemical, manufacturing, service, and energy indus- tries, as well as nested

Network flow analysis is employed to effect local optimizations and then dynamic programming ideas are introduced in order to piece the local solutions together into an optimal