Maxflow Problem

Post on 06-Apr-2018

221 views 0 download

transcript

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 1/73

Network Flow, ChinesePostman,Topological Sorting and

Planarity Detection and Embedding

Firas M Abu Hassan20911833

CS 530: Design and Analysis of Algorithms 

Fall 2010 1

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 2/73

Network flows Problem

Flow network: a flow network G = (V,E) is a directed graphin which each edge (u,v) ∈ E has a nonnegative capacityc(u,v) >= 0. if (u,v) ∉ E , we assume that c(u,v) = 0.

We distinguish two vertices in flow network , source  s andsink  t.

The source produces the material at a steady rate . The sink consumes the material at a steady rat

Objective : how much of material can be imposed throughnetwork that network can handle. (Find a maximal flow over adirected graph)

2

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 3/73

Definition of Flow

Each edge can carry an entity called “flow”. 

For flow on an edge to be valid, it must satisfythree conditions: Capacity constraint: The flow can not be greater than

the capacity of the edge f ( u,v ) <= c ( u,v )

Skew symmetry: The flow on the edge (u,v) is equal tothe negation of the flow on the edge (v,u)

Flow conservation: The total flow entering a vertex(excluding the source or sink) must equal the totalpositive flow leaving that vertex.

V vV v

t v  f  vs  f    f   ),(),(||3

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 4/73

Definition of Flow

S t

v1

v2

v3

v4

Flow network: directed graph G=(V,E) 

S t

v1

v2

v3

v4

u v6/12

u v6/6

f(u,v)=6

f(u,v)=6

Flow below capacity

Maximum flow

8

3

6

8

6

6

3

3

Example: oilpipeline

4

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 5/73

Example of a Flow:

f(v2, v1) = 1, c(v2, v1) = 4. f(v1, v2) = -1, c(v1, v2) = 10.

f(v3, s) + f(v3, v1) + f(v3, v2) + f(v3, v4) + f(v3, t) =

0 + (-12) + 4 + (-7) + 15 =

0

flowcapacity

capacity

5

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 6/73

Residual Networks

The residual capacity of an edge (u,v) in a network with a

flow f is given by:

),(),(),( vu f vucvuc f 

• The residual network of a graph G induced by a flow f  is the graph including only the edges with positive

residual capacity, i.e., ( , ), wheref f 

G V E  {( , ) : ( , ) 0}f f 

E u v V V c u v  

6

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 7/73

The basic Ford Fulkerson method

1 for each edge (u, v)   E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t in theresidual network G f  

5 do cf (p) = min {cf (u, v) | (u, v) is in p}

6 for each edge (u, v) in p 

7do

f [u, v] = f [u, v] + cf (p)8 f [v, u] = - f [u, v]

7

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 8/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

14

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

(residual) network Gf 

8

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 9/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

0 /12

0 /14

(residual) network Gf  1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

9

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 10/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

14

(residual) network Gf  1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

10

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 11/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

14

(residual) network Gf 

temporary variable:cf (p) = 12

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

11

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 12/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

14

(residual) network Gf 

temporary variable:cf (p) = 12

S t

v1

v2

v3

v4

12/12

14

new flow network

G

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

12

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 13/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

14

(residual) networkGf 

S t

v1

v2

v3

v4

12/12

14

new flow network G

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

13

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 14/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

14

(residual) network Gf 

S t

v1

v2

v3

v4

12/12

14

new flow network

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

14

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 15/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

14

(residual) network Gf 

S t

v1

v2

v3

v4

12/12

14

new flow network

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

15

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 16/73

The basic Ford Fulkersonaugmenting paths Algorithm 

(residual) networkGf 

S t

v1

v2

v3

v4

12/12

14

new flow network

G

temporary variable:cf (p) = 4

S t

v1

v2

v3

v4

12

14

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

16

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 17/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

14

(residual) networkGf 

S t

v1

v2

v3

v4

12/12

new flow network

G temporary variable:cf (p) = 4

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

17

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 18/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

10

(residual) network Gf 

S t

v1

v2

v3

v4

12/12

new flow network

4

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

18

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 19/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

10

(residual) network Gf 

S t

v1

v2

v3

v4

12/12

new flow network

4

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

19

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 20/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

10

(residual) networkGf 

S t

v1

v2

v3

v4

12/12

new flow network

4

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

20

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 21/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

10

(residual) networkGf 

S t

v1

v2

v3

v4

12/12

new flow network

4

temporary variable:cf (p) = 7

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

21

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 22/73

The basic Ford Fulkersonaugmenting paths Algorithm 

S t

v1

v2

v3

v4

12

10

(residual) networkGf 

S t

v1

v2

v3

v4

12/12

new flow network

G

4

temporary variable:cf (p) = 7

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

22

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 23/73

The basic Ford Fulkersonaugmenting paths Algorithm 

(residual) networkGf 

S t

v1

v2

v3

v4

12/12

new flow network

S t

v1

v2

v3

v4

12

3

11

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

23

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 24/73

The basic Ford Fulkersonaugmenting paths Algorithm 

(residual) network Gf 

S t

v1

v2

v3

v4

12/12new flow network

S t

v1

v2

v3

v4

12

3

11

Finally we have:| f | = f (s, V) = 23

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  

5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

24

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 25/73

Analysis of the Ford Fulkerson algorithm 

The running time depends on how the augmenting path p in line 4 isdetermined.

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

25

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 26/73

Analysis of the Ford Fulkerson algorithm 

O(|E|)

O(|E|) O(|E||fmax|)

running time: O ( |E| |fmax|)with fmax as maximumflow

1 for each edge (u, v)  E [G] 

2 do f [u, v] = 0

3 f [v, u] = 0

4 while there exists a path p from s to t 

in the residual network G f  5 do cf (p) = min{cf (u, v) | (u, v) p}

6 for each edge (u, v) in p 

7 do f [u, v] = f [u, v] + cf (p)

8 f [v, u] = - f [u, v]

O(|E|)

26

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 27/73

Ford Fulkerson – cuts of flow networks

A cut (S,T) of a flow network G=(V,E) is a partiton of V into Sand T = V \ S such that s S and t T.

S t

v1

v2

v3

v4

12/12

11/14

TS

For example:S = {s,v1,v2) , T = {v3,v4,t}Net flow f(S ,T) = f(v1,v3) + f(v2,v4) + f(v2,v3)

= 12 + 11 + (-0) = 23

Max Flow = Min Cut = 23

27

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 28/73

Edmonds-Karp Algorithm

Edmonds-Karp = Ford-Fulkerson using breadth-first search inline 4 to find an augmenting path,i.e., the augmenting path found is shortest in terms of thenumber of edges.

Edmonds-Karp runs in O(VE2) time… 28

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 29/73

Analysis of Edmonds-Karp

If the Edmonds-Karp algorithm is run on a flow networkG = (V, E) with source s and sink t, then the total numberof flow augmentations performed by the algorithm is

O(VE).

Since, breadth-first search can be implemented in O(E)time, the running time of Edmonds-Karp is O(VE * E) =

O(VE2).

29

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 30/73

A BFS Example

L =  s   0

30

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 31/73

 

L =  s   0

L =  a, c  1

A BFS Example

31

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 32/73

 

L =  s   0

L =  a, c  1

L =  d, e, f   2

A BFS Example

32

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 33/73

 

L =  s   0

L =  a, c  1

L =  d, e, f   2

L =  b , g  3

A BFS Example

33

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 34/73

 

L =  s   0

L =  a, c  1

L =  d, e, f   2

L =  b , g  3

A BFS Example

34

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 35/73

 

0

1

1

2

2

2

3

3

d (b ): shortest distance from s to b 

A BFS Example

35

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 36/73

History

36

Discoverer  Method  Big-Oh Year Ford, Fulkerson  Augmenting path mF*1955 

Edmonds-Karp  Shortest path m2n1970 

Dinitz  Shortest path mn2 1970 

Edmonds-Karp, Dinitz  Capacity scaling m2 logn1972 

Dinitz-Gabow  Capacity scaling mn logn1973 

Karzanov  Preflow-push n3 1974 

Sleator-Tarjan  Dynamic trees mn log n1983 

Goldberg-Tarjan  FIFO preflow-push mn log (n2 / m)1986 

. . .  . . . . . .. . . 

Goldberg-Rao  Length functionm3/2 log (n2 / m) log n

mn2/3 log (n2 / m) log n1997 

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 37/73

CHINESE POSTMAN ALGORITHM

• This is used when we are trying to find the shortest

route round a network such all the arcs are travelled

along at least once.

37

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 38/73

Edmond’s Algorithm 

procedure FloydWarshallWithPathReconstruction ()

for k := 1 to n

for i := 1 to n

for j := 1 to nif path[i][k] + path[k][j] < path[i][j] then 

path[i][j] := path[i][k]+path[k][j];

next[i][j] := k;

Run time = O(n 3 )

38

Add thi t th t k

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 39/73

A postman starts at the depot T and has to deliver mailalong all the streets shown in the network below. Find aroute that means he travels the shortest possible distance.

HG

FE

DCB

A

0.8

1.7

1.01.0

2.0 0.750.2

0.4 0.6

0.5 1.5

1.70.6

0.9

1.6

0.9

0.3

Odd vertices are B, G, H & T  Possible pairings:

BG & HT 

Route: BEG & HECT 

Length: 1.7 + 1.8 = 3.5

BH & GT Route: BEH & GECT 

Length: 1.5 + 2.0 = 3.5

BT & GH

Route: BCT & GH

Length: 0.8 + 0.9 = 1.7

The shortest extra route is:

Add this to the network

Possible route is:

TABEAGHEGHFDFECDTCBCT 

39

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 40/73

A

B C

D

EF

GH

Route is:

T A B E A G H E G H F D F E C D T C B C T 

Total length of alloriginal paths is16.45 km

Add on the extraroutes BCT and GH= 1.7 km

Shortest length =16.45 + 1.7 = 18.15 km

40

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 41/73

Topological Sort

it should be possible to perform all the tasks insuch an order as to satisfy all of thedependencies

Such as order is called a topological sort of the

vertices

The requirement is to list all of the vertices suchthat in that list, vi precedes v j whenever a path

exists from vi to v j 

If this is not possible, this would imply the existenceof a cycle.

Theorem:41

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 42/73

Topological Sort 

int topologicalOrderTraversal( ){

int numVisitedVertices = 0;

while(there are more vertices to be visited){

if(there is no vertex with in-degree 0)

break;else{

select a vertex v that has in-degree 0;

visit v;

numVisitedVertices++;

delete v and all its emanating edges;

}}

return numVisitedVertices;

} Running time: O(V + E) =O(n)

42

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 43/73

Example

Let us define the table of in-degrees

VertexIn-

degree

1 02 1

3 3

4 3

5 2

6 0

43

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 44/73

Example

And a queue into which we can insert vertices 1and 6

1 6

Queue

VertexIn-

degree

1 02 1

3 3

4 3

5 2

6 0

44

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 45/73

Example

We dequeue the head (1), decrement the in-degree of all adjacent vertices: 2 and 4

2 is decremented to zero: enqueue 2

6 2

QueueSort1

VertexIn-

degree

1 02 0

3 3

4 2

5 2

6 0

45

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 46/73

Example

We dequeue 6 and decrement the in-degree of alladjacent vertices

Neither is decremented to zero

2

QueueSort1, 6

VertexIn-

degree

1 02 0

3 2

4 2

5 1

6 0

46

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 47/73

Example

We dequeue 2, decrement, and enqueue vertex 5

5

QueueSort1, 6, 2

VertexIn-

degree

1 02 0

3 1

4 1

5 0

6 0

47

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 48/73

Example

We dequeue 5, decrement, and enqueue vertex 3

3

QueueSort1, 6, 2, 5

VertexIn-

degree

1 02 0

3 0

4 1

5 0

6 0

48

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 49/73

Example

We dequeue 3, decrement 4, and add 4 to thequeue

4

QueueSort1, 6, 2, 5, 3

VertexIn-

degree

1 02 0

3 0

4 0

5 0

6 0

49

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 50/73

Example

We dequeue 4, there are no adjacent vertices todecrement the in degree

QueueSort1, 6, 2, 5, 3, 4

VertexIn-

degree

1 02 0

3 0

4 0

5 0

6 0

50

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 51/73

Example

The queue is now empty, so a topological sort is1, 6, 2, 5, 3, 4

51

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 52/73

Planar Graphs

Can be drawn on the plane without crossings

We will : 

Testing if a graph is planarFinding a nice drawing of a planar graph

52

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 53/73

Testing if a graph is planar

Euler’s Formula 

-  region : is a part of the plane completelydisconnected off from other parts of the planeby the edges of the graph. 

r = |E | - |V | + 2

c = r - |E | + |V | c must equal 2 for planar graphs. 

53

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 54/73

54

Face-Edge Handshaking

DEF: The degree  of a region  F  is the number ofedges at its boundary, and is denoted by deg(F ).

THM: Let G be a planar graph with region set R .

Then:

 RF 

F  E  )deg(21 ||

 

Ex: (4+4+4+4+4+4)/2 = 12

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 55/73

55

Proving that Q4 is Non-Planar

Now we have enough invariants to prove thatthe 4-cube is non-planar.

1) Count the number of vertices and edges:

|V | = 16 (twice the number for 3-cube)

|E | = 32 (twice the number for 3-cube plusnumber of vertices in 3-cube)

2) Suppose 4-cube were planar so by Euler’sformula number of regions would be:

r = 32-16+2=18 

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 56/73

56

Proving that Q4 is Non-Planar

3) Calculate the degree of each region

In our case, this give |E | ½·18·4=36

contradicting |E | = 32 !

Thus 4-cube cannot be planar. • 

 RF 

F  E  )deg(2

1 ||

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 57/73

Testing if a graph is planar

Circle-Chord Method

Step One: Find a circuit that contains all thevertices of the graph.

Step Two: Draw this circuit as a large circle.

a b c d

e hgfgh

f

bc

e

d

a

57

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 58/73

Testing if a graph is planarStep Three: Choose one chord, and decide to draw it either inside or outsidethe circle. If chosen correctly, it will force certain other chords to be drawnopposite to the circle. (Inside if the first chord was drawn outside, and viceversa.)

gh

f

bc

e

d

a

Since the chords could be drawn withoutcrossing, this graph is planar.

a b c d

e hgf

58

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 59/73

a

e

f d

c

bh

g

a

f

e

d

c

bh

g

Testing if a graph is planar

• Kuratowski theoremA graph is planar if and only if it does not contain the K5

or the K3,3 

59

S i Al ith

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 60/73

Sugiyama Algorithm

Remove cycles

Generate levelling

Sugiyama 1979

Running time O(|V||E|\log|E)

11

3

8

1

5

10 7

4

12

6

9

2

60

S i Al ith

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 61/73

Sugiyama Algorithm

Algorithm

Remove cycles

Generate levelling

11

85

10 7

12

6

9

31 421

61

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 62/73

Sugiyama Algorithm

Algorithm

Remove cycles

Generate levelling

11

8 10

129

31

5 7

4

6

21

2

62

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 63/73

Sugiyama Algorithm

Algorithm

Remove cycles

Generate levelling

1112

3

8

1

5

10

7

42

9

6

1

2

3

63

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 64/73

Sugiyama Algorithm

Algorithm

Remove cycles

Generate levelling

Split long edges

11

3

8 9

1

5

10

7

42

12

6

1

2

3

4

64

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 65/73

Sugiyama Algorithm

Algorithm

Remove cycles

Generate levelling

Split long edges

Reduce crossings11

6

3

8 9

1

5

10

7

42

12

1

2

3

4

65

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 66/73

Sugiyama Algorithm

Algorithm

Remove cycles

Generate levelling

Split long edges

Reduce crossings11

6

3

8 9

1

5

10

7

42

12

1

2

3

4

66

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 67/73

Sugiyama Algorithm

Algorithm

Remove cycles

Generate levelling

Split long edges

Reduce crossings11

6

3

89

1

5

10

7

42

12

1

2

3

4

67

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 68/73

Sugiyama Algorithm

Algorithm

Remove cycles

Generate levelling

Split long edges

Reduce crossings11

6

3

89

1

5

10

7

42

12

1

2

3

4

68

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 69/73

Sugiyama Algorithm

Algorithm

Remove cycles Generate levelling

Split long edges

Reduce crossings11

6

3

89

1

5

10

7

42

12

1

2

3

4

69

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 70/73

Sug ya a go t

Algorithm

Remove cycles Generate levelling

Split long edges

Reduce crossings11

6

3

89

1

5

10

7

42

12

1

2

3

4

70

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 71/73

g y g

Algorithm

Remove cycles Generate levelling

Split long edges

Reduce crossings11

6

3

89

1

5

10

7

42

12

1

2

3

4

71

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 72/73

g y g

Algorithm

Remove cycles Generate levelling

Split long edges

Reduce crossings

Join long edges 11

6

3

89

1

5

10

7

42

12

1

2

3

4

72

Sugiyama Algorithm

8/3/2019 Maxflow Problem

http://slidepdf.com/reader/full/maxflow-problem 73/73

g y g

Algorithm

Remove cycles Generate levelling

Split long edges

Reduce crossings

Join long edges

Basic properties

2 level crossing minimisation

Minimum edge set whoseremoval eliminates crossings

11

6

3

89

1 42

10

12

57

1

2

3

4