3.2 matchings and factors: algorithms and applications this copyrighted material is taken from...

35
3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory , 2 nd Ed., by Doug West; and is not for further distribution beyond this course. These slides will be stored in a limited-access location on an IIT server and are not for distribution or use beyond Math 454/553. 1

Upload: dale-thomas

Post on 14-Jan-2016

212 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

3.2 Matchings and Factors: Algorithms and Applications

This copyrighted material is taken from Introduction to Graph Theory, 2nd Ed., by Doug West; and is not for further distribution beyond this course.

These slides will be stored in a limited-access location on an IIT server and are not for distribution or use beyond Math 454/553.

1

Page 2: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

3.2.1. Augmenting Path Algorithm Overview

Two theorems to recall:

Theorem 3.1.10 (Berge). A matching M in a graph G is a maximum matching in G iff G has no M-augmenting path.

Theorem 3.1.16 (König,Egerváry) If G is bipartite, then a maximum matching and a minimum vertex cover of G have the same size (i.e., ’(G)=(G)).

3.2.1 Augmenting path algorithm (for bipartite graphs)

Input An X,Y-bigraph G, a partial matching M, unsaturated U X

Output One of two possibilities:An augmenting path from U to some y YA minimum vertex cover Q

2

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 3: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Maximum Matching/Minimum Cover Algorithm

3.2.1 Augmenting path algorithm (for bipartite graphs)

Input An X,Y-bigraph G, a partial matching M, unsaturated U X

Output One of two possibilities:An augmenting path from U to some y YA minimum vertex cover Q

Maximum Matching/Minimum Cover Algorithm

Input An X,Y-bigraph G, a partial matching M (e.g., M=)Output a maximum matching and a minimum vertex coverRun Algorithm 3.2.1 on M (’(G)–M) times, using the augmenting path output to increase M each time until |M|=’(G) Run Algorithm 3.2.1 once more to produce a minimum vertex cover

3

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 4: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

3.2.1. Augmenting Path Algorithm Framework

Algorithm (Augmenting path algorithm)

Input An X,Y-bigraph G, a (partial matching) M, and

the M-unsaturated vertices U XIdea Explore augmenting paths to all possible vertices, marking explored vertices and their predecessors, and tracking reached vertices S X and T YInitialization S=U and T=Iteration [Details next slide]

4

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 5: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

3.2.1. Augmenting Path Algorithm Details

Algorithm (Augmenting path algorithm)

Input An X,Y-bigraph G, a (partial matching) M, and

the M-unsaturated vertices U XInitialization S=U and T=Iteration If S is all marked, stop and output M and Q=T (X–S).

Otherwise, explore from an unmarked x S.

For each y N(x) with xy M:

(1) If y is unsaturated, halt and report an augmenting U,y-path

(2) If y is saturated, for the unique edge yw M:(1) Update T T {y}

(2) Update S S {w}

(3) Mark x and iterate

5

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 6: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

Run 1 Input: M= S=U=X, T=, x=x1

6

SSS S S

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 7: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

Run 1: y1 unsaturated. Halt and augment M.

7

T

SSS S S

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 8: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

8

Run 2 Input: M={x1y1} S={x2, x3, x4, x5}, T=, x=x2

SSS S

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 9: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

9

Run 2: From x2, explore y1 and its matched neighbor

T

SSS S S

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 10: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

10

Run 2: From x1, explore y2.y2 is unsaturated: halt and augment M.

T

SSS S S

T

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 11: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

11

Run 3 Input: M={x1y2, x2y1} S={x3, x4, x5}, T=, x=x3

SS S

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 12: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

12

Run 3: From x3, explore y3.y3 unsaturated; halt and report augmenting path.

SS S

T

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 13: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

13

Run 4 Input: M={x1y2, x2y1, x3y3} S={x4, x5}, T=, x=x4

S S

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 14: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

14

Run 4: From x4, explore y2,y3 and their (distinct) matched neighbors.

SSS

T T

S

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 15: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

15

Run 4: From x1, and x3, explore to find y1 via non-matching edges. Explore back up to x2 via a matching edge.

SSS

T T

S

T

S

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 16: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

16

Run 4 (continued): x5 is still unexplored. Explore from x5 to find unsaturated vertex y4. Terminate and report an M-augmenting path.

SSS S

T TT

S

T

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 17: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

17

Run 5 Input: M={x1y2,x2y1,x3y3,x5y4} S={x4}, T=, x=x4

S

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 18: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

18

Run 5: From x4, explore y2,y3 and their (distinct) matched neighbors.

SSS

T T

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 19: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

19

Run 5: From x1, and x3, explore to find y1 via non-matching edges. Explore back up to x2 via a matching edge.

SSS S

T TT

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 20: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Augmenting path algorithm example

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

20

Termination: No vertex of S is unexplored.Output: maximum matching M={x1y2,x2y1,x3y3,x5y4}Minimum vertex cover Q=T (X–S) ={x5,y1,y2,y3}.

SSS S

T TT

Q

QQQ

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 21: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Proof of Repeated Augmenting Path Algorithm

3.2.2 Theorem Repeatedly applying the Augmenting Path Algorithm to a bipartite graph produces a matching and a vertex cover of equal size.

Proof Repeatedly run Algorithm 3.2.1, increasing the matching size by 1 each time, until the first time an augmenting path is not returned. We must argue that the set Q returned by Algorithm 3.2.1 is a vertex cover with size equal to that of the matching M initializing this last run.

We must argue that Q=T (X–S) is a vertex cover. It suffices to prove there are no edges of G between S and Y–T.(1) There is no matching edge of M between S and Y–T:There is certainly no matching edge incident to U. (unsaturated)Vertices of S–U only have matching edges to T.

(2) There is no non-matching edge of E(G)–M between S and Y–T:

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 22: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Proof of Repeated Augmenting Path Algorithm

3.2.2 Theorem Repeatedly applying the Augmenting Path Algorithm to a bipartite graph produces a matching and a vertex cover of equal size.

Proof (continued) (1) There is no matching edge of M between S and Y–T:There is certainly no matching edge incident to U. (unsaturated)Vertices of S–U only have matching edges to T.

(2) There is no non-matching edge of E(G)–M between S and Y–T: While exploring vertices in S, all non-matching edges are followed so that the other endpoints are placed in T.

(3) Q=T (X-S) has |Q| = |M|:

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 23: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Proof of Repeated Augmenting Path Algorithm

3.2.2 Theorem Repeatedly applying the Augmenting Path Algorithm to a bipartite graph produces a matching and a vertex cover of equal size.

Proof (continued) (1) There is no matching edge of M between S and Y–T.(2) There is no non-matching edge of E(G)–M between S and Y–T.

(3) Q=T (X–S) has |Q| = |M|:T is involved in exactly T matching edges since these vertices wereexplored through augmenting paths from S.

X–S is saturated; otherwise these vertices would contribute to U.There are no edges from T to X–S because T matches to S–U.Therefore |Q| = |T| + |X–S| = |M|.

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 24: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Weighted Bipartite Matching

In weighted bipartite matching, we have a simple bigraph with weighted edges and want a matching with maximum possible total edge weight.

Input A simple X,Y-bigraph G and a weight function w:E(G)[0, )Output A matching M with maximum w(M)=e M w(e)

Without loss of generality, we may assume G = Kn,n by adding any missing vertices needed to make |X|=|Y| and assigning edge weight 0 to any missing edges.

Comments• Edge weights of Kn,n are encoded in an nn matrix • Maximum bipartite matching can be solved by maximum weighted

bipartite matching, by assigning edge weight 1 to all edges.• We will define weighted covers, which generalize vertex covers.

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 25: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Transversals and (Weighted) Covers

0 0 0 0 0

6 4 4 4 3 6

4 1 1 4 3 4

5 1 4 5 3 5

9 5 6 4 7 9

8 5 3 6 8 3

Transversal: A set M of n entries of an nn, matrix, no two in the same column or row. Its weight is the sum of the entries.Cover: A pair of vectors (u,v)=(u1,…,un;v1,…,vn) such that every entry wi,j of the matrix satisfies wi,j = ui+vj.

u

v

w(M)=23

w(u,v)=32

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

v1 v2 v3 v4 v5

u1

u2

u3

u4

u5

Page 26: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

3.2.7 Maximum Transversals and Minimum Covers

3.2.7. Lemma. (Duality of weighted matching and weighted cover problems) For a perfect matching M and a weighted cover (u,v) in a weighted bipartite graph G, c(u,v)>=w(M). Also, c(u,v)=w(M) iff M consists of edges xiyj such that ui+vj=wi,j. In this case, M and (u,v) are optimal.

0 1 2

4 4 4 4

2 1 1 4

3 1 4 5

u

v

w(M)=12

w(u,v)=12

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 27: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Finding Maximum Transversals and Minimum Covers

We know:

1. We can always find a cover by setting ui =maxj wi,j for all rows i=1,…,n

2. If we find M, (u,v) with w(M)=c(u,v), by Lemma 3.2.7 we are done.

Question But how do we get from Item 1 to Item 2?

Answer Compare c(u,v) versus the weights matrix [wi,j] to

• Make the equality subgraph of edges for which wi,j=ui+vj

• Improve (u,v) using a vertex cover of the equality subgraph

• Iterate until w(M)=c(u,v). Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 28: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

The Equality Subgraph

3.2.8 Definition. The equality subgraph Gu,v for a weighted cover (u,v) is the spanning subgraph of Kn,n whose edges are the pairs xiyj such that wi,j=ui+vj. In the cover, the excess for i,j is ui + vj - wi,j.

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

0 0 0 0 06 4 1 6 2 3

7 5 0 3 7 6

8 2 3 4 5 8

6 3 4 6 3 4

8 4 6 5 8 6

u

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

vEquality subgraph for (u,v)

Matrix entries with wi,j=ui+vj

Page 29: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

The Equality Subgraph and Excess Matrix

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

0 0 0 0 06 4 1 6 2 3

7 5 0 3 7 6

8 2 3 4 5 8

6 3 4 6 3 4

8 4 6 5 8 6

u

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

v

Equality subgraph for (u,v)

Matrix entries with wi,j=ui+vj

uv

excess matrix for (u,v)

0 0 0 0 0

6 2 5 0 4 3

7 2 7 4 0 1

8 6 5 4 3 0

6 3 2 0 3 2

8 4 2 3 0 2

Page 30: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

3.2.9. Hungarian Algorithm (Maximum Weighted Matching/Minimum Weighted Cover)

Algorithm (Hungarian Algorithm)

Input An n x n matrix of nonnegative edge weights of Kn,n

Idea Iteratively adjust the cover (u,v) until the equality subgraph Gu,v has a perfect matching

Initialization Any cover (u,v), such as ui=maxi wi,j and vj=0

Iteration Find a maximum matching M in Gu,v. If M is a perfect matching, stop and output M and (u,v) as a maximum weight matching and minimum weight cover.

Otherwise:

Let = smallest excess in Gu,v of an edge from X-R to Y-T.

Replace ui ui- for all xi X-R.

Replace vj vj+ for all yj Y-T.

Form the new equality subgraph Gu,v and repeat.

30

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 31: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Hungarian Algorithm Example

0 0 0 0 06 4 1 6 2 3

7 5 0 3 7 6

8 2 3 4 5 8

6 3 4 6 3 4

8 4 6 5 8 6

uv

w(M)=21 w(u,v)=35

0 0 0 0 0

6 2 5 0 4 3

7 2 7 4 0 1

8 6 5 4 3 0

6 3 2 0 3 2

8 4 2 3 0 2

uv excess matrix

T T

R

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

T T

R

Equality subgraphvertex cover: Q=R T

Add =1 to T, subtract from X–R.

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 32: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Hungarian Algorithm Example

0 0 0 0 06 4 1 6 2 3

7 5 0 3 7 6

8 2 3 4 5 8

6 3 4 6 3 4

8 4 6 5 8 6

uv

w(u,v)=35T T

R

Add =1 to T, subtract from X–R.

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

0 0 1 1 05 4 1 6 2 3

6 5 0 3 7 6

8 2 3 4 5 8

5 3 4 6 3 4

7 4 6 5 8 6

uv

w(u,v)=33

The total cover weight must decrease becausenew cover weight – old cover weight = (|T| – |X–R|)

Note: |T| – |X–R| = |T| – (n – |R|) =|T| + |R| – n < n – n = 0 So: new cover weight – old cover weight < 0.

Page 33: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Hungarian Algorithm Example

0 0 0 0 06 4 1 6 2 3

7 5 0 3 7 6

8 2 3 4 5 8

6 3 4 6 3 4

8 4 6 5 8 6

uv

w(u,v)=35T T

R

Add =1 to T, subtract from X–R.

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

0 0 1 1 05 4 1 6 2 3

6 5 0 3 7 6

8 2 3 4 5 8

5 3 4 6 3 4

7 4 6 5 8 6

uv

w(u,v)=33

When the matrix weights are rational, transform the problem by multiplying through by the least common denominator. Then 1 is guaranteed, and the cover weight w(u,v) decreases by at least 1 in each iteration.See the text for the proof when the matrix has an irrational weight.

Page 34: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Hungarian Algorithm Example

0 0 1 1 05 4 1 6 2 3

6 5 0 3 7 6

8 2 3 4 5 8

5 3 4 6 3 4

7 4 6 5 8 6

uv

w(M)=21 w(u,v)=33

0 0 1 1 0

5 1 4 0 4 2

6 1 6 4 0 0

8 6 5 5 4 0

5 2 1 0 3 1

7 3 1 3 0 1

uv excess matrix

T T

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

T T T

Equality subgraphvertex cover: Q=R T

T

Add =1 to T, subtract from X-R.

Contains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.

Page 35: 3.2 Matchings and Factors: Algorithms and Applications This copyrighted material is taken from Introduction to Graph Theory, 2 nd Ed., by Doug West; and

Hungarian Algorithm Example

0 0 2 2 14 4 1 6 2 3

5 5 0 3 7 6

7 2 3 4 5 8

4 3 4 6 3 4

6 4 6 5 8 6

uv

w(M)=31 w(u,v)=31

0 0 2 2 1

4 0 3 0 4 2

5 0 5 4 0 0

7 5 4 5 4 0

4 1 0 0 3 1

6 2 0 3 0 1

uv excess matrix

T T

x1 x2 x3 x4 x5

y1 y2 y3 y4 y5

T

Matching weight=cover weight.Halt and output M, and (u,v).

equality subgraphContains copyrighted material from Introduction to Graph Theory by Doug West, 2nd Ed. Not for distribution beyond IIT’s Math 454/553.