chapter 8. topics in graph theory weiqi luo ( 骆伟祺 ) school of software sun yat-sen university...

105
Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆骆骆 ) School of Software Sun Yat-Sen University Email [email protected] Office A309

Upload: warren-banks

Post on 20-Jan-2016

220 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

Chapter 8. Topics in Graph Theory

Weiqi Luo (骆伟祺 )School of Software

Sun Yat-Sen UniversityEmail : [email protected] Office : A309

Page 2: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

8.1. Graphs 8.2. Euler Paths and Circuits 8.3. Hamiltonian Paths and Circuits 8.4. Transport Networks 8.5. Matching Problems 8.6. Coloring Graphs

2

Chapter eight: Topics in Graph Theory

Page 3: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Graph A graph G=(V, E, γ) consists of a finite set V of objects

called vertices, a finite set E of objects called edges, and a function γ that assigns to each edge a subset {v, w}, where v and w are vertices (and may be the same).

End points

If γ(e)={v, w}, then vertices v and w are called the end points of e.

8.1 Graphs

3

Page 4: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 1 & 2 Let V={1,2,3,4} and E={e1,e2,e3,e4,e5}. Let γ be defined

by γ(e1)= γ(e5)={1,2}, γ(e2)={4,3}, γ(e3)={1,3}, γ(e4)={2,4} .

Then G=(V,E,γ) is a graph.

8.1 Graphs

4

1 2

4 3

G

1 2

3 4

G

1 2 43

G

Isomorphic Graphs

Page 5: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Degree

The degree of a vertex is the number of edges having that vertex as an end point.

Loop An edge is referred to as a loop if the edge is from a

vertex to itself.

Note: a loop contributes 2 to the degree of a vertex, since that vertex serves as both end points of the loop.

Isolated A vertex with degree 0 is called an isolated vertex.

8.1 Graphs

5

Page 6: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 3

8.1 Graphs

6

A B

EC

D

p

q

r

s

tu

a b

d e

c

2

1

3

5

6

4

A: 2 B:4 C: 1 D: 3 E: 2

a: 4 b:2 c: 3 d: 1 e: 0

All edges withdegree 2

Page 7: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Path in a Graph A path п in a graph G consists of a pair (Vп, Eп) of

sequences: a vertex sequence Vп : v1, v2, …, vk and an edge sequence E п :e1, e2,…,ek-1 for which

1. Each successive pair vi, vi+1 of vertices is adjacent in G, and edge ei has vi and vi+1 as end points for i=1, …, k-1;

2. No edge occurs more than once in the edge sequence.

8.1 Graphs

7

Page 8: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Circuit (cycle)

A circuit is a path that begins and ends at the same vertex.

Simple A path is called simple if no vertex appears more than

once in the vertex sequence, except possibly if v1=vk. In this case, the path is called a simple circuit.

8.1 Graphs

8

Page 9: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Connected, Disconnected & Components A graph is called connected if there is a path from any

vertex to any other vertex in the graph. Otherwise, the graph is disconnected. If the graph is disconnected, the various connected pieces are called the components of the graph.

8.1 Graphs

9

A B

EC

D

p

q

r

s

tu

Connected DisconnectedTwo components

2

1

3

5

6

4

Page 10: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Some important special families of graphs will be useful in our discussions.

1. Un (discrete graph) denote the graph with n vertices and no edges.

2. Ln (linear graph) denote the graph with n vertices and with edges {vi,vj} for 1≤ i <n

8.1 Graphs

10

U2 U5

L2 L5

Page 11: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

3. Kn (complete graph) denote the graph with n vertices and with an edge {vi, vj} for all i and j.

Regular

If each vertex of a graph has the same degree as every other vertex, the graph is called regular.

e.g. Kn and Fig. 8.6

8.1 Graphs

11

K3 K4

K5

K2=L2

Page 12: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Subgraph Support that G=(V, E, γ) is a graph. Choose a subset E1

of the edges in E and a subset V1 of the vertices in V, so that V1 contains (at least) all the end points of edges in E1. Then H=(V1,E1, γ1) is also a graph where γ1 is γ restricted to edges in E1. Such a graph H is called a subgraph of G.

8.1 Graphs

12

Page 13: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

The subgraph Ge

Deleting one edge and no vertices

8.1 Graphs

13

ba

cd

i f

gh

G

ba

cd

i f

gh

Ge

e={a,b}

Page 14: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 8

8.1 Graphs

14

ba

cd

i f

gh

cd

i f

gh

b

cd

i f

gh

ba

cd

i f

ghG

Page 15: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 9 (Quotient graph GR)

Let G be the graph (without multiple edges) of the following figure, and let R be the equivalence relation on V defined by the partition.

{{a, m, i}, {b, f, j}, {c, g, k}, {d, h, l}}

8.1 Graphs

15

fm

gh

i j

kl

ba

cd

[a] [b]

[c][d]

GR

[m] [j]

[k][h]

=GR

Page 16: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 9 If S is also an equivalence relation on V defined by the

partition.

{{i, j, k, l}, {a, m},{f, b, c}, {d}, {g}, {h}}

8.1 Graphs

16

fm

gh

i j

kl

ba

cd

[a]

[i]

[b]

[h] [g]

[d] GS

Page 17: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

The Quotient graph Ge

If e is an edge between vertex v and w in a graph G={V,E, γ}, then we consider the equivalence relation whose partition consists of {v, w} and {vi}, for each vi v, vi w. (merging v and w and leaving others alone)

8.1 Graphs

17

fm

gh

[i]

kl

ba

cd Ge

fm

gh

i j

kl

ba

cdG

e={i, j}

Page 18: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Homework Ex. 6, Ex. 16, Ex. 20, Ex. 22, Ex. 23, Ex. 29

8.1 Graphs

18

Page 19: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Seven Bridges of Königsberg (from Wikipedia)

8.2 Euler Paths and Circuits

19

Vertex: Land

Edge: Bridge

Question: Is it possible to walk through the city that would cross each bridge once and only once?

Page 20: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Euler path

A path in a graph G is called an Euler path if it includes every edge exactly once.

Euler circuit

An Euler circuit is an Euler path that is a circuit.

About Leonhard Euler:

http://en.wikipedia.org/wiki/Leonhard_Euler

8.2 Euler Paths and Circuits

20

Page 21: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 1

8.2 Euler Paths and Circuits

21

Page 22: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 2

8.2 Euler Paths and Circuits

22

E

B

D

A

C

An Euler Path: E, D, B, A, C

1

2

5

4

3

An Euler circuit: 5, 3, 2, 1, 3, 4, 5

Page 23: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 2

8.2 Euler Paths and Circuits

23

E

B

D

A

C

2

1

3

5

6

4

Q: An Euler Circuit? Q: An Euler Path?

A: No A: No

Page 24: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 3

8.2 Euler Paths and Circuits

24

Q: Is it possible to begin in a room or outside and take a walk that goes through each door exactly once?

Vertex: Room or OutsideEdge: door

Page 25: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Two Questions 1. Is it possible to determine whether an Euler path or

Euler circuit exists without actually finding it?

Theorem 1 (Euler circuit) &

Theorem 2 (Euler path)

2. If exists Euler circuit, how to find it effectively?

Fleury’s algorithm

8.2 Euler Paths and Circuits

25

Page 26: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Theorem 1

(a) If a graph G has a vertex of odd degree, there can be no Euler circuit in G

8.2 Euler Paths and Circuits

26

E

B

D

A

C V of odd degree

…1 2 3 2n

2n+1

Begin at v

V of odd degree

…1 2 3 2n

2n+1

End at v

Page 27: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Theorem 1 (b) If G is a connected graph and every vertex has even

degree, then there is an Euler circuit in G.

The Strategy of this proof (b) :

Support there is a largest (smallest) object and construct a larger (smaller) object of the same type thereby creating a contradiction.

8.2 Euler Paths and Circuits

27

Page 28: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Proof (b) Basic Step: |V|=1, 2 is true (why?)

Induction Step : |V|=1,2…k is true |V|=k+1 is true

1. Assume G is connected and has more than one vertex, then there exists a simple path having the longest possible length (why?). Let its vertex sequence п0: v1 v2,…,vs.

Since vs has even degree and п0 uses only one edge that has vs as a vertex, there must be an edge e not in п0 that also has vs as a vertex.

If the other vertex of e is not in п0, then we can construct a simple path longer than п0(why?), which is a contradiction.

Thus e has some vi as its other vertex, and therefore we have a simple circuit vi vi+1, … vs, vi in G.

8.2 Euler Paths and Circuits

28

Page 29: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

2. Choose the longest circuit п in G, and delete all edges in п (but no vertices).

Assuming there is no Euler circuits in G, then п cannot contain all edges of G (why?).

Let G1 be the graph formed form G by deleting all edges in п (but no vertices). Since п is a circuit, deleting its edges will reduce the degree of every vertex by 0 or 2, so G1 is also a graph with all vertices of even degree. Choose any connected component in G1 and call this graph G2 (G2 may be G1).

Then G2 has also a circuit п’ (why?).

8.2 Euler Paths and Circuits

29

Page 30: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

3. Consider п and п’ in G

case #1: if п and п’ have vertices in common, e.g. v’, then we can construct a circuit in G that is longer than п by combing п and п’ at v’ (contradiction!)

Case #2: If there is no common vertex in п and п’. Then |VG2| < |VG|, then G2 has a Euler Circuit (why? ) , then G becomes not connected (why?) , which is a contradiction.

Therefore, the assumption is wrong, namely, G has Euler circuit.

8.2 Euler Paths and Circuits

30

п П’v’

case #1

Page 31: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Theorem 2 (a) If a graph G has more than two vertices of odd degree,

then there can be no Euler path in G

Proof: Let v1, v2, v3 be vertices of odd degree. Any possible Euler path must leave (or arrive at) each of v1, v2, v3 with no way to return (or leave) since each of these vertices has odd degree. One vertex of these three vertices may be the beginning of the Euler path and another the end, but this leaves the third vertex at one end of an untraveled edge. Thus there is no Euler path.

8.2 Euler Paths and Circuits

31

Page 32: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Theorem 2 (b) If G is connected and has exactly two vertices of odd

degree, there is an Euler path in G. Any Euler path in G must begin at one vertex of odd degree and end at the other.

Proof: Let u and v be the two vertices of odd degree. Adding the edge {u, v} to G produces a connected graph G’ all of whose vertices have even degree. By Theorem 1(b), there is an Euler circuit п’ in G’. Omitting {u, v} from п’ produces an Euler path that begins at u (or v) and ends at v (or u).

8.2 Euler Paths and Circuits

32

Page 33: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 4

8.2 Euler Paths and Circuits

33

Each of the four vertices has degree 3. No Euler path and Euler circuit.

There has exactly two vertices of odd degree. There is no Euler circuit, but there must be an Euler path.

Every vertex has even degree, thus the graph must have an Euler circuit.

Page 34: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Bridge An edge is a bridge in a connected graph G if deleting it

would create a disconnected graph.

8.2 Euler Paths and Circuits

34

A B

EC

D

p

q

r

s

tu

r is a bridge

s is a bridge

t is a bridge

Page 35: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Algorithm FLEURY’S ALGORITHM Let G={V,E,γ} be a connected graph with each vertex of even

degree. Step 1 Select an edge e1 that is not a bridge in G. Let its vertices be v1, v2. Let п

be specified by Vп: v1, v2 and Eп: e1. Remove e1 from E and let G1 be the resulting subgraph of G.

Step 2 Suppose that Vп: v1, v2 … vk and Eп: e1 e2 … ek-1 have been constructed so far, and that all of these edges and any resulting isolated vertices have been removed from V and E to form Gk-1.

Since vk has even degree, and ek-1 ends there, there must be an edge ek in Gk-1

that also has vk as a vertex. If there is more than one such edge, select one that is not a bridge for Gk-1. Denote the vertex of ek other than vk by vk+1, Extend Vп: v1, v2 … vk vk+1 and Eп: e1 e2 … ek-1 ek.

Step 3 repeat Step 2 until no edges remain in E

8.2 Euler Paths and Circuits

35

Page 36: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 6

Use Fleury’s algorithm to construct an Euler circuit for the following graph.

8.2 Euler Paths and Circuits

36

A

B

D

C E

F

H

G

Page 37: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Homework Ex. 6, Ex. 12, Ex. 14, Ex. 15, Ex. 21, Ex. 25

8.2 Euler Paths and Circuits

37

Page 38: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Hamiltonian path A Hamiltonian path is a path that contains each vertex

exactly once.

Hamiltonian circuit A Hamiltonian circuit is a circuit that contains each vertex

exactly once except for the first vertex.

8.3 Hamiltonian Paths and Circuits

38

Page 39: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Loop and Multiple edges

8.3 Hamiltonian Paths and Circuits

39

Loops and multiple edges are of no use in finding Hamiltonian circuits, since loops Could not be used, and only one edge can be used between any two vertices.

Thus we support that any graph in this section has no loops or multiple edges.

Page 40: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

An Example for Hamiltonian circuit

8.3 Hamiltonian Paths and Circuits

40

Page 41: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 1

8.3 Hamiltonian Paths and Circuits

41

a

c

d

b

e

D

A

C

B

Has Hamiltonian pathBut no Hamiltonian circuit

Has Hamiltonian path& Hamiltonian circuit

2

1

3

5

6

4

A B

E

E

A

No Hamiltonian Path

Page 42: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 2 Any complete graph Kn has Hamiltonian circuits? In

fact, starting at any vertex, you can visit the other vertices sequentially in any desired order.

8.3 Hamiltonian Paths and Circuits

42

K3 K4

K5

Q: How about K2?K2

n should be larger than 2

Page 43: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Two Questions1. Is it possible to determine whether a Hamiltonian path

or circuit exists?

has not been completely answered

2. If there must be a Hamiltonian path or circuit, it there an efficient way to find it?

is still unanswered.

8.3 Hamiltonian Paths and Circuits

43

Page 44: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Theorem 1 Let G be a connected graph with n vertices, n>2, and no

loops or multiple edges.

G has a Hamiltonian circuit if for any two vertices u and v of G that are not adjacent, the degree of u plus the degree of v is greater than or equal to n.

Corollary 1

G has a Hamiltonian circuit if each vertex has degree greater than or equal to n/2.

8.3 Hamiltonian Paths and Circuits

44

Page 45: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Theorem 2 Let the number of edges of G be m. Then G has a Hamiltonian circuit if m ≥

(n2-3n+6)/2, where n is the number of vertices

Proof: Support u & v are non-adjacent vertices in G. Let deg(x) for the degree of x. Let H be the graph produced by eliminating u and v from G along with any edges that have u or v as end points. Then H has n-2 vertices and m- deg(u) –deg(v) edges.

The maximum number of edges that H could possibly have is

And then we have m – deg(u)-deg(v) <= ½(n2-5n+6 )

thus deg(u) +deg(v) >= n (Theorem 1 holds)

8.3 Hamiltonian Paths and Circuits

45

2 22

( 2)( 3) 1( 5 6)

2 2n

n nC n n

Page 46: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 3

8.3 Hamiltonian Paths and Circuits

46

C

B

D

G

H

F

A

E

|V| = 8

For any pair of nonadjacent vertices u and vdeg(u) + deg(v) = 4 < 8

Therefore, the conditions given in Theorem 1 & 2 are sufficient, but not necessary, for the conclusion.

A Hamiltonian Circuit

Page 47: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Traveling salesperson problem Find a Hamiltonian circuit (or path) for which the total

sum of weights in the path is a minimum.

For example, the vertices might represent cities, the edges, lines of transportation, and the weight of an edge, the cost of traveling along the edge.

8.3 Hamiltonian Paths and Circuits

47

B D

CA

F G

H

E

6 2

6

2

3 2

34

5

5

4

Page 48: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Homework

Ex. 8, Ex. 13, Ex. 18, Ex.20, Ex. 21

8.3 Hamiltonian Paths and Circuits

48

Page 49: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Transport network A transport network (or network) is a connected diagraph N

with the following properties:

a) There is a unique node, the source, that has in-degree 0, labeled the source node 1;

b) There is a unique node, the sink, that has out-degree 0. labeled as the sink node n if N has n nodes;

c) The graph N is labeled. The label, Cij, on edge (i, j) is a nonnegative number called the capacity of the edge.

8.4 Transport Networks

49

1

4

2

5

3

6

5

4

2 2

33

3 4

Source Sink

Here, if (i, j) in N, then (j, i) is not

Page 50: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Flows A flow in a network N is a function that assigns to each edge

(i, j) of N nonnegative number Fij that does not exceed Cij.

Fij denotes the amount of material passing through the edge (i,j) when the flow is F.

we also require that for each node k must equal to the sum of the Fkj on edges leaving node k (conservation of flow).

8.4 Transport Networks

50

1

4

2

5

3

6

(5,3)

(4,2)

(2,1) (2,0)

(3,2)(3,2)

(3,3)(4,3)

(Cij, Fij ) Value of the flow (value(F)) The sum of the flows leavingthe source or entering the sink

value(F)=5 in this example

2+1=3 3+0=3

Page 51: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 2

8.4 Transport Networks

51

1

2

3

4

(4,4)

(6,4)

(2,2)

(6,6)

(4,2)

value(F)= 4+4 = 6+2 = 8

1

2

3

4

(4,4)

(6,6)

(2,0)

(6,6)

(4,4)

value(F)= 6+4 = 6+4 = 10

Maximum flows problem: how to determine the maximum value of a flow though the network and to describe a flow that has the maximum value

<In the first figure, there is a mistake for using the edge from node 3 to 2.

Page 52: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Virtual flow

8.4 Transport Networks

52

1

2

3

4

(6,4)

(2,2)

(4,2)

(2,2)

Virtual Path п: 1 2 3 4

If there is a virtual flow of 2 units through edge (2,3), then we can increase the flows though edge(1,2) and (3,4) by 2 units.

1

2

3

4

(4,4)

(6,4)

(2,2)

(6,6)

(4,2)

1

2

3

4

(4,4)

(6,4)

(2,2)

(6,6)

(4,2)

SymmetricClosure

Page 53: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Let N be a network and let G be the symmetric closure of N. Choose a path in G and an edge (i, j) in this path.

case # 1:

(i, j) is in N, then we say this edge has positive excess capacity if eij=Cij-Fij>0.

case #2:

(i, j) is not in N, i.e. virtual flow, we say (i, j) has excess capacity eij= Fji if Fji>0.

Then increasing flow through edge (i, j) will have the effect of reducing Fji , note (j, i) in N.

8.4 Transport Networks

53

Page 54: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Labeling algorithm Step 1: Let N1 be the set of all nodes connected to the source by an

edge with positive excess capacity. Label each j in N1 with [Ej, 1] where Ej is the excess capacity e1j of edge (1, j). The 1 in the label indicates that j is connected to the source, node 1.

8.4 Transport Networks

54

N1= {2, 4}

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=5e21=0

e45=3 e54=0

e23=3 e32=0

e25=2e52=0

e56=4e65=0

e36=3e63=0

[4, 1]

[5, 1]

Page 55: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Step 2: Let node j in N1 be the node with smallest node number and let N2(j) be the set of all unlabeled nodes, other than the source, that are joined to node j and have positive excess capacity. Suppose that node k is in N2(j) and (j, k) is the edge with positive excess capacity. Label node k with [Ek, j] where Ek is the minimum of Ej and the excess capacity ejk of edge (j,k). When all the nodes in N2(j) are labeled in this way, repeat this process for the other nodes in N1. Let N2=Uj in N

1 N2(j).

8.4 Transport Networks

55

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=5e21=0

e45=3 e54=0

e23=3 e32=0

e25=2e52=0

e56=4e65=0

e36=3e63=0

[4, 1]

[5, 1]

[2, 2]

[3, 2]

j = 2

N2 = {3, 5}

Page 56: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Step 3: Repeat Step 2, labeling all previously unlabeled nodes N3 that can be reached form a node in N2 by an edge having positive excess capacity. Continue this process forming sets N4, N5,…, until after a finite number of steps either

(i) the sink has not been labeled and no other nodes can be labeled. It can happen that no nodes have been labeled;

(ii) the sink has been labeled.

8.4 Transport Networks

56

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=5e21=0

e45=3 e54=0

e23=3 e32=0

e25=2e52=0

e56=4e65=0

e36=3e63=0

[4, 1]

[5, 1]

[2, 2]

[3, 2]

[3, 3]

Page 57: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

For case (i):

the algorithm terminates and the total flow then is a maximum flow

For case (ii):

the sink has been labeled with [En, m], where En is the amount of extra flow that can be made to reach the sink though a path п.

Examine п in reverse order.

If edge (i. j) in N, decrease the excess capacity eij by the same amount, and increase eji (virtual edge) by En.

Return to Step 1.

8.4 Transport Networks

57

Page 58: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Case (ii)

8.4 Transport Networks

58

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=5e21=0

e45=3 e54=0

e23=3 e32=0

e25=2e52=0

e56=4e65=0

e36=3e63=0

[4, 1]

[5, 1]

[2, 2]

[3, 2]

[3, 3]

П : 1 2 3 6

Update eij & eji in П

Page 59: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Case (ii)

8.4 Transport Networks

59

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=2e21=3

e45=3 e54=0

e23=0 e32=3

e25=2e52=0

e56=4e65=0

e36=0e63=3

[4, 1]

[5, 1]

[2, 2]

[3, 2]

[3, 3]

П : 1 2 3 6

Page 60: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Repeat Step 1

consider node 1

Note: E2 is now only 2 (e12=2)

8.4 Transport Networks

60

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=2e21=3

e45=3 e54=0

e23=0 e32=3

e25=2e52=0

e56=4e65=0

e36=0e63=3

[4, 1]

[2, 1]

Page 61: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Repeat Step 2:

consider node 2

Node 2 can no longer be used to label node 3, since e23=0

8.4 Transport Networks

61

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=2e21=3

e45=3 e54=0

e23=0 e32=3

e25=2e52=0

e56=4e65=0

e36=0e63=3

[4, 1]

[2, 1]

[2, 2]

Page 62: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Repeat Step 2:

consider node 5

8.4 Transport Networks

62

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=2e21=3

e45=3 e54=0

e23=0 e32=3

e25=2e52=0

e56=4e65=0

e36=0e63=3

[4, 1]

[2, 1]

[2, 2]

[2, 5]

Page 63: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Repeat Step 2:

consider node 5

Case (ii) occurs

8.4 Transport Networks

63

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=2e21=3

e45=3 e54=0

e23=0 e32=3

e25=2e52=0

e56=4e65=0

e36=0e63=3

[4, 1]

[2, 1]

[2, 2]

[2, 5]

Page 64: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Case (ii)

8.4 Transport Networks

64

П : 1 2 5 6

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=0e21=5

e45=3 e54=0

e23=0 e32=3

e25=0e52=2

e56=2e65=2

e36=0e63=3

[4, 1]

[2, 1]

[2, 2]

[2, 5]

Update eij & eji in П

Page 65: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Repeat Step 1:

8.4 Transport Networks

65

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=0e21=5

e45=3 e54=0

e23=0 e32=3

e25=0e52=2

e56=2e65=2

e36=0e63=3

[4, 1]

Page 66: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Repeat Step 2:

8.4 Transport Networks

66

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=0e21=5

e45=3 e54=0

e23=0 e32=3

e25=0e52=2

e56=2e65=2

e36=0e63=3

[4, 1] [3, 4]

Page 67: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Case (ii)

8.4 Transport Networks

67

1

4

2

5

3

6

e14=4e41=0

e24=2e42=0

e12=0e21=5

e45=3 e54=0

e23=0 e32=3

e25=0e52=2

e56=2e65=2

e36=0e63=3

[4, 1] [3, 4]

[2, 5]

П : 1 4 5 6

Update eij & eji in П

Page 68: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Case (ii)

8.4 Transport Networks

68

1

4

2

5

3

6

e14=2e41=2

e24=2e42=0

e12=0e21=5

e45=1 e54=2

e23=0 e32=3

e25=0e52=2

e56=0e65=4

e36=0e63=3

[4, 1] [3, 4]

[2, 5]

П : 1 4 5 6

Page 69: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Repeat Step 1

8.4 Transport Networks

69

1

4

2

5

3

6

e14=2e41=2

e24=2e42=0

e12=0e21=5

e45=1 e54=2

e23=0 e32=3

e25=0e52=2

E56=0e65=4

e36=0e63=3

[2, 1]

Page 70: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Step 2

8.4 Transport Networks

70

[1, 4]

1

4

2

5

3

6

e14=2e41=2

e24=2e42=0

e12=0e21=5

e45=1 e54=2

e23=0 e32=3

e25=0e52=2

E56=0e65=4

e36=0e63=3

[2, 1]

Page 71: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Step 3

label node 2 using virtual edge (5, 2)

case (i) occurs

8.4 Transport Networks

71

[1, 4]

1

4

2

5

3

6

e14=2e41=2

e24=2e42=0

e12=0e21=5

e45=1 e54=2

e23=0 e32=3

e25=0e52=2

E56=0e65=4

e36=0e63=3

[2, 1]

[1, 5]

Page 72: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Case (i)

8.4 Transport Networks

72

1

4

2

5

3

6

e14=2e41=2

e24=2e42=0

e12=0e21=5

e45=1 e54=2

e23=0 e32=3

e25=0e52=2

E56=0e65=4

e36=0e63=3

1

4

2

5

3

6

22

20

3

35

4

Page 73: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Cut A cut in a network N as a set K of edges having the property

that every path from the source to the sink contains at least one edge from K.

Therefore, a cut can “cut” a network into two pieces, one containing source and one containing the sink.

If the edges of a cut were removed, noting flow from the source to the sink.

Capacity of a cut The capacity of a cut K, c(K) is the sum of the capacities of

all edges in K.

8.4 Transport Networks

73

Page 74: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 4

8.4 Transport Networks

74

1

4

2

5

3

6

43

22

3

35

4

Cut K1 Cut K2

c(K1)=10 c(K2)=7

Page 75: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

If F is any flow and K is any cut, then

value(F) ≤ c(K)

since all parts of F must pass though the edges of K.

If some flow F and some cut K, value(F)=c(K), then the flow F uses the full capacity of all edges in K.

Then F would be a flow with maximum value, since no flow can have value bigger then c(K).

Similarly, K must be a minimum capacity cut, since every cut must have capacity at least equal to value(F).

8.4 Transport Networks

75

Page 76: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Theorem 1: The Max Flow Min Cut Theorem A maximum flow F in a network has value equal to the

capacity of a minimum cut of the network.

Proof:

Suppose the labeling algorithm has been run and stop at case (i). Then the sink has not been labeled. Divide the nodes into two sets,

M1 : the source and all nodes that have been labeled)

M2 : all unlabeled nodes except the source.

Let K consist of all edges of N that connect a node in M1 with a node in M2

8.4 Transport Networks

76

Page 77: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Suppose (i, j) is an edge in K, so that i in M1, j in M2. The

final flow F produced by the algorithm must result in (i,j) carrying its full capacity; otherwise, we could use node i and the excess capacity to label j.

Therefore, the value of the final flow of the algorithm is equal to the capacity c(K), and so F is a maximum flow.

8.4 Transport Networks

77

Source Sink

…Cut K

Labeled M1 Unlabeled M2

Page 78: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example

8.4 Transport Networks

78

[1, 4]

1

4

2

5

3

6

e14=2e41=2

e24=2e42=0

e12=0e21=5

e45=1 e54=2

e23=0 e32=3

e25=0e52=2

E56=0e65=4

e36=0e63=3

[2, 1]

M1

M2

K={e23, e56 } and both edges have their full capacities, 5 and 4, respectively

[1, 5]

Page 79: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 5

8.4 Transport Networks

79

1

4

2

5

3

6

e14=2e41=2

e24=2e42=0

e12=0e21=5

e45=1 e54=2

e23=0 e32=3

e25=0e52=2

E56=0e65=4

e36=0e63=3

Cut K

Cut K={e56, e36 } with c(K)= 7= value(F)

Page 80: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Homework Ex, 4, Ex. 8, Ex. 13, Ex. 18

8.4 Transport Networks

80

Page 81: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Network with multiple sources & sinks

8.5 Matching Problems

81

1

4

2

5

3

2

3

2

4

6

7

2

2

4

3

Page 82: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 1

8.5 Matching Problems

82

1

4

2

5

3

2

3

2

4

6

7

2

2

4

3

a

Super source

11

11

11

11

11

b

Super sink

Set the new added edges with the sum of all capacities leaving sources o N

N

Then the labeling algorithm can be used in the resulting network N’ to find a maximal flow for the original one N

Page 83: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Matching Problem Let A and B be two finite sets, and R be a relation from A to

B. A matching function M is a one-to-one function from a subset of A to a subset of B.

We say a is matched with b if M(a)=b.

A matching function M is compatible with R if M R, ⊆namely, if M(a)=b, then a R b.

Maximal matching Given any relation R from A to B, a matching M that is

compatible with R is called maximal if its domain is as large as possible and is complete if its domain is A.

8.5 Matching Problems

83

Page 84: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 3 Let A be a set of girls and B a set of boys attending a

school dance. Define R by a R b if and only if a knows b. A matching function M is defined from A to B by M(a)=b if a and b dance the third dance together. M is compatible with R if each girl knows her partner for the third dance.

8.5 Matching Problems

84

Page 85: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 4 Let A={s1,s2,s3,s4,s5} be a set of students working on a

research project and B={b1,b2,b3,b4,b5} be a set of reference books on reserve in the library for the project. Define R by si R bk if and only if student si wants to sign out book bk. A matching of students to books would be compatible with R if each student is matched with a book that he or she wants to sign out.

8.5 Matching Problems

85

Page 86: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 5

8.5 Matching Problems

86

s5

s4

s3

s2

s1

b5

b4

b3

b2

b1M(s1)=b2, M(s2)=b1, M(s3)=b3, M(s4)=b4

Page 87: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Find a maximal matching

8.5 Matching Problems

87

s5

s4

s3

s2

s1

b5

b4

b3

b2

b1

x y

1

1

1

1

1 1

1

1

1

1

1

Page 88: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

A simplified version

8.5 Matching Problems

88

3

2

5

4

16

(1,0 )

(1,0 )

(1,0 )

(1,0 )

(1,0 )

(1,0 )

(1,0 )

[1,1]

[1,1]

[1,2]

[1,2]

[1,4]

Page 89: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

A simplified version

8.5 Matching Problems

89

3

2

5

4

16

(1,0 )

(1,0 )

(1,0 )

(1,0 )

(1,0 )

(1,0 )

(1,0 )

Page 90: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

A simplified version

8.5 Matching Problems

90

3

2

5

4

16

(0,1 )

(1,0 )

(0,1 )

(1,0 )

(1,0 )

(0,1 )

(1,0 )

Page 91: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

A simplified version

8.5 Matching Problems

91

3

2

5

4

16

(0,1 )

(1,0 )

(0,1 )

(1,0 )

(1,0 )

(0,1 )

(1,0 )

[1,1]

[1,3][1,4]

[1,2]

[1,5]

Virtual Flow

Page 92: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

A simplified version

8.5 Matching Problems

92

3

2

5

4

16

(0,1 )

(1,0 )

(0,1 )

(1,0 )

(1,0 )

(0,1 )

(1,0 )

Page 93: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

A simplified version

8.5 Matching Problems

93

3

2

5

4

16

(0,1 )

(0,1 )

(1,0 )

(0,1 )

(0,1 )

(0,1 )

(0,1 )

Page 94: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

A simplified version

8.5 Matching Problems

94

3

2

5

4

16

(0,1 )

(0,1 )

(1,0 )

(0,1 )

(0,1 )

(0,1 )

(0,1 )

M(2)=5, M(3)=4

Page 95: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Theorem 1 (Hall’s Marriage Theorem) Let R be a relation from A to B. Then there exists a

complete matching M if and only if for each

X⊆A, |X|≤|R(X)|

We omit the proof of the result.

8.5 Matching Problems

95

Page 96: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 6 Let MR be the matrix of a marriage suitability relation

between five men and five woman. Can each man marry a suitable woman?

8.5 Matching Problems

96

11000

00011

10100

00101

01010

RM

w1 w2 w3 w4 w5

m1

m2

m3

m4

m5

Way one: Use the enlarged network to find a maximum flow

Way two: Use the Theorem 1

Let S be any subset of the men and E be theset of edges that begin in S, then |E|=2|S|. Each edge in E must terminate in a node of R(S). But we know the number of edges terminating at elements of R(S) is exactly 2|R(S)|. Thus, 2|S| ≤2|R(S)| , and so |S| ≤ |R(S)|. By theorem 1, there is a complete match.

Page 97: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Homework

Ex. 7, Ex. 13, Ex. 16

8.5 Matching Problems

97

Page 98: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Coloring of the graph G

Suppose that G=(V,E,γ) is a graph with no multiple edges, and C={c1,c2,…,cn} is any set of n “colors”. Any function f: VC is called a coloring of the graph G using n colors. For each vertex v, f(v) is the color of v.

Proper coloring

A coloring is proper if any two adjacent vertices v and w have different colors.

Chromatic number of G ( χ (G) ) The smallest number of colors needed to produce a proper

coloring of a graph G is called the chromatic number of G

8.6 Coloring Graphs

98

Page 99: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example 1

8.6 Coloring Graphs

99

w

r

w

br

r

w

r

yb

Solution 1 (3 colors) Solution 2 (4 colors)

Q: using two of fewer colors? Impossible in this example.

χ (G)=3

Page 100: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

The chromatic number of Kn

8.6 Coloring Graphs

100

K3 K4

K5

χ(K3)=3 χ(K4)=4 χ(K5)=5

Page 101: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Planar graph

The graph can be drawn in a plane so that no edges cross except at vertices.

For example:

8.6 Coloring Graphs

101

A B D F

C E

Page 102: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Some examples of Planar graph

8.6 Coloring Graphs

102

Page 103: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Example for a non-planar graph

8.6 Coloring Graphs

103

K5

Page 104: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Four color theorem

Refer to

http://en.wikipedia.org/wiki/Four_color_theorem

8.6 Coloring Graphs

104

Page 105: Chapter 8. Topics in Graph Theory Weiqi Luo ( 骆伟祺 ) School of Software Sun Yat-Sen University Email : weiqi.luo@yahoo.com Office : A309 weiqi.luo@yahoo.com

School of Software

Homework Ex. 2, Ex. 4, Ex. 8

8.6 Coloring Graphs

105