Вы находитесь на странице: 1из 7

10/5/2010

Graph Coloring

A graph is k-colored if each vertex is labeled with an


integer from 1 to k and no edge is adjacent to vertices
with the same label.
ECE-256a
lecture 3

Malgorzata Marek-Sadowska
Electrical and Computer Engineering Department
Engineering I, room 4111
mms@ece.ucsb.edu. 3-colored 2-colored

256a 1 256a 2

The chromatic number, C(G), of a graph, G is The four color problem


the smallest k for which it can be k-colored.
(Guthrie, 1853): Can a map always be 4-colored?

Any graph in which all vertices are of degree


d or less can be d+1 colored.
C
A C
Koenig’ss theorem:
Koenig
B E
A B E
A graph can be 2-colored if and only if it has
no circuits of odd length. D
D F
F

256a 3 256a 4

Planar Graphs
(Heawood, 1890): A map can always be 5-colored.
A C
G H G H
B D

E
F I J I J

W
Reducible configurations
g W
V
V
X
X

Z Y
Z Y

A graph is planar iff it can be drawn in the plane so that


Haken and Appel, 1976: A map can always be 4-colored edges meet only at vertices.

256a 5 256a 6

1
10/5/2010

A graph is planar iff it can be drawn on a sphere so that Fary’s theorem


edges meet only at vertices.
Any planar graph can be drawn so that all edges are
N
straight line segments.
A B
A
B
C
P
D C
D
Theorem (Maly): Any planar graph can be drawn planarly for arbitrary
P’
position of its vertices.

A C B
A
B D

D C

256a 7 256a 8

Dual of a planar graph


Euler’s theorem
A
In any planar graph of V vertices, E edges, and V A
F faces (outside counts as face) W C X E V
B D W C X E
Y Z B D
V+F=E+2 Y
Z
F
F
A B
A
B Graph G: Dual of G:
C V=6, E=9, F=5. V=5, E=9, F=6.
V
D C
D
W
V=4, E=6, F=4 X

Y Z

256a 9 256a 10

Finding the min-cut of a planar graph


S’ Min path
5 4 3
5
4 3 3 Min cut
4 2
S’ 1 2 S’
S 1 1 2 T 1
5 6 5
5 3 6
3
5 T’ 5
4 4 3 4 4 3
3 3
S 1 1 22 T S 1 1 22 T
S’
4 3 5 5 6 5 5 6
5
3 2 3 3
4
1 1 2
5 T’ T’
5 3 6

T’
256a 11 256a 12

2
10/5/2010

The flow in a network


Flow: An assignment of numbers, f(e) to each edge, e,
such that:
Connected acyclic directed graph with one source and
one sink.
1. For each edge, e, 0 ≤ f ( e ) ≤ c ( e)
Edge capacity, c(e) >=0
X
10 2. For each vertex other than S and T:
A
7
12 3
 f in =  f out
S T
sink Value of flow =  f out (eS ) =  f in (eT )
source 9 4 13

B 10 Y

256a 13 256a 14

Finding a flow Finding a flow (cont.)

X Flow path X Flow path


10 10
A
7
A
7/4
V=min(12,10,7-4)=3
12 3 12 3
S T S T
Saturated edge
source sink source sink
9 4 9/4 4/4
13 13

B 10 Y B 10 Y
V=min(9,4,7)=4 V=min(9-4,10,13)=5

Current flow F=4 Add new flow, V=8. Current flow F=4+8=12

256a 15 256a 16

Finding a flow (cont.) Finding a flow (cont.)


Back edge of a path
X (canceling
X a flow)
Flow path
10/3 10/3
A A
7/7 7/7
12/3 3 12/6 3/3
S T S T
Saturated edge Saturated edge
source sink source sink
9/9 4/4 9/9 4/4
13/5 13/8

B 10/5 Y B 10/5 Y
V=min(12-3,3,13-5)=3
V=min(12-6,10-3,4,10-5,13-8)=4
Add new flow, V=3. Current flow F=12+3=15 Add new flow, V=4. Current flow F=15+4=19

256a 17 256a 18

3
10/5/2010

Finding a flow (cont.) A cut is the set of edges connecting a set of vertices,VS
(including S) to the remaining vertices, VT (including T).
A cut
X
10/7
A
7/7
12/10 3/3
S T VS VT
source sink
9/9 4/0 13/12

B 10/9 Y cut

Max flow =19 The capacity of a cut is the sum of the capacities
of the edges fromVS to VT .
Total capacity of forward edges across the cut is 19.
Stop, the flow is best possible.
256a 19 256a 20

Max-flow min-cut theorem


An augmenting path is a path from S to T
consisting of unsaturated forward edges
In a network the value of a maximum flow is equal and backward edges with f(e) > 0.
to the capacity of a minimum cut.
S
11/7 7/7 12/0 9/3 T
Corollary: 8/5

The augmenting value of such a path of i edges


In the maximum flow, all the edges VS VT in the minimum
is: Min ( Δ (e)) i
cut will be saturated. None of the edges VT VS will be used. i

Where, for forward edges, Δ (e) = c (e) − f (e)


and for backward edges, Δ ( e) = f ( e )
E.g., V=min(11-7, 7, 12-0, 5, 9-3) = 4.

256a 21 256a 22

Augmenting path theorem Augmenting Path Theorem

A flow is maximal if and only if it admits no augmenting L(S)=0, i=0


flow from S to T. Label with i+1, all unlabeled vertices connected to vertices
with i by:

(1) An unsaturated forward edge (edge with c(e)>f(e)), or


3/0 4/4
(2) A used backward edge (f(e)>0)
3/3
4/4 6/4
5/4
S T Increment i and repeat

source 10/7
8/3 3/0 Stop when L(T) = i or no more vertices can be labeled.
7/4
3/0 sink

5/3

256a 23 256a 24

4
10/5/2010

Augmenting path theorem Max-flow Min-cut Algorithm (Ford and Fulkerson)

Find an augmenting path. (If none exists, halt. Flow is max)


Find value, V, of augmenting path.
3/0 4/4

X 3/3 Augment flow with V,


4/4 6/4
5/4
S T Forward edges:
g f<- f+V,,
source 10/7
8/3 3/0 7/4 sink backward edges: f<- f-V,
3/0

5/3 Repeat.

256a 25 256a 26

Matching problem Flow network


Jobs
U V W X Y Z
U
A 1 A 1 1
B 1 1 1 V
1 B 1
Workers C 1 1
Assignment matrix S 1
1 W T
D 1 1 C 1
1
1 1
E 1 1 1 X
D 1
F 1 1
1 1 Y
1 E 1
1

F 1
Find maximum matching of workers to jobs 1 Z
1

256a 27 256a 28

Solving the matching problem Solving the matching problem


Unmatched Unmatched

U V W X Y Z A U U V W X Y Z A U
A 1 A 1
B V B V
B 1 1 1 S B 1 1 1 S
C 1 T C 1 T
C W C W
D 1 1 D 1 1
D D
E 1 1 X E 1 1 X
F 1 F 1
E E
Y Y
F F
Initial matching Z Improved matching Z

Augmenting path

256a 29 256a 30

5
10/5/2010

Assignment problem Hungarian Method


Given an n x n cost matrix A=[aij], aij=cost of assigning worker i to job j.
Konig’s Theorem
Find an assignment which minimizes the cost.

If A is a matrix, and m is the maximum number of independent


4 3 1 2 zero elements of A, then the minimum number of lines covering
-2 –1 6 8 all zeros is m.
A= 1 1 2 3
-1
1 -1
1 4 1
Also, the solution does not change if the matrix A is replaced by
A set of elements of a matrix is independent if no two elements lie the matrix b, obtained by subtracting from each element of A
on the same line (row or column). an arbitrary constant.

Need to choose n independent elements [aij] whose sum is minimum.

256a 31 256a 32

Kuhn’s Algorithm

Step 1. Subtract the smallest element in A from each aij. New matrix A1 Step 2. Find a minimum set Si of lines (rows and columns), ni, which
has all [aij] >=0 and at least one 0. cover all zeros of Ai.
Set i=1. If ni=n, Stop, there are n independent zeros, whose locations
determine final assignment. Calculate the value of assignment
using original costs aij for these locations.
4 3 1 2 6 5 3 4
A= -2 –1 6 8 A1= 0 1 8 10 Step 3. If ni < n, let let ki > 0 denote the smallest element of Ai which is
1 1 2 3 3 3 4 5 not in any line of Si. For each line in Si, add ki to every element
-1 -1 4 1 1 1 6 3 off that
h liline, andd subtract
b ki from
f every element
l off Ai. Call
C ll new
matrix Ai+1.

Step 4. Set i=i+1. Go to step 2.


Min aij = -2 n1 = 1, k1 = 1
The smallest element in the reminder
Min # rows and columns that cover all the zeros

256a 33 256a 34

6 4 0 1 6 4 0 1
4 3 1 2 6 5 3 4 0 0 5 7
-2 –1 6 8 A3= A4= 0 0 5 7
A= A1= 0 1 8 10 3 2 1 2 2 1 0 1
1 1 2 3 3 3 4 5 1 0 3 0 1 0 3 0
-1 -1 4 1 1 1 6 3

Min aij = -2 n1 = 1, k1 = 1 n3 = 3, k3 = 1 n4 = 3, k4 = 1

5 3 0 0 6 4 0 1
6 4 2 3 6 4 0 1 A5= 0 0 6 7 0 0 5 7
0 0 7 9 A3= 0 0 5 7 1 0 0 0 2 1 0 1
A2=
3 2 3 4 3 2 1 2 1 0 4 0
1 0 5 2 1 0 3 0

n5 = 4
n2 = 2, k2 = 2 n3 = 3, k3 = 1

256a 35 256a 36

6
10/5/2010

Solution
Find 4 independent zeros.

5 3 0 0 6 4 0 51 3 0 0 6 4 0 1
A5= 0 0 6 7 A50= 0 5 0 7 0 6 7 0 0 5 7
1 0 0 0 2 1 0 11 0 0 0 2 1 0 1
1 0 4 0 1 0 4 0

Cost1 = a21 + a42 + a13 + a34 = 1

Cost2 = a21 + a32 + a13 + a44 = 1

256a 37

Вам также может понравиться