The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

THE MARRIAGE PROBLEM 1. Bipartite Graphs De nition 1. A graph G is bipartite if there are subsets R and B of the vertex set V such that (a) R\ B = ;; (b) R[ B = V;

Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by , 2016-02-05 20:51:03

THE MARRIAGE PROBLEM - The University of New Mexico

THE MARRIAGE PROBLEM 1. Bipartite Graphs De nition 1. A graph G is bipartite if there are subsets R and B of the vertex set V such that (a) R\ B = ;; (b) R[ B = V;

THE MARRIAGE PROBLEM

1. Bipartite Graphs

Definition 1. A graph G is bipartite if there are subsets R and B of
the vertex set V such that

(a) R ∩ B = ∅;
(b) R ∪ B = V ;
(c) R = ∅ and B = ∅;
(d) Every edge in G is incident to one vertex in R and one vertex

in B.

So a graph is bipartite if you can separate the vertices into a red
team and a blue team so that there are no edges between teammates.
There may be more than one way to do this. The graph G is bipartite.

•c •b
•d •a
G = •e
•f

We can demonstrate this with

R = {a, b, e} B = {c, d, f }

or with R = {b, c, e} B = {a, d, f },
as shown here:

•c •b •c •b
•d •a •d •a

•e •f or •e •f

Often we will redraw the graph so the “red” set is on top and the “blue”
set is on the bottom. With the second choice of R and B that could

1

THE MARRIAGE PROBLEM 2

look lile this: •a •d •f

•b •c •e

It is very easy to tell if a graph is bipratite. You can just start
assigning red and blue (plus or minus) to vertices, starting at any
vertex and then moving to other vertices that are adjecent to those
already marked. You alternate as you must, and if you are forced to
put a plus by a plus or a minus by a minus, you stop, as the graph
is not bipartite. (If the graph is not connected, you can attack each
connected component separately.)

Example 1. Is this bipartite?

••

••

•• ••

••

••

Here’s a solution. Mark a vertex a “plus” at random:

••

• •+

•• ••

••

••

Now from any marked vertex we mark another, with the opposite sign:

•• •• ••

• •+ • •+ • •+

• • • • • • • • • • • •
− − −

•• •+ • •+ •

•• •• • •


THE MARRIAGE PROBLEM 3

•• • • • •+
− −

• •+ • •+ • •+

•+ • • • •+ • • • •+ • ••
− − −

•+ • •+ • •+ •

• • • • • •
− − −

• •+ • •+ • •+
− − −

• •+ • •+ • •+

•+ • • • •+ • • • •+ • • •
− − − − − −

•+ • •+ • •+ •


• • • •+ • •+
− − −

• •+ • •+
− −

• •+ • •+


•+ • •+ • •+ • •+ •
− − − −

•+ • •+ •
− −

• •+ • •+
− −

This graph is bipartite. Every edge is between a plus and a minus.

Example 2. Is this bipartite?

••

••

•• ••

••

••

Here’s a solution.

•• •• •+ •

•• • • • •
− −

•• •+ • •• •+ • •• •+ •

•• •• ••

•• •• ••

THE MARRIAGE PROBLEM 4

•+ • •+ • •+ •

• • • • • •
− − −

• • •+ • • • •+ • • • •+ •
− − −

•• •• ••

•• •+ • •+ •


•+ • •+ • •+ •
• − −
• • •
− •+ •+ − • − •
•+ •+ •+ •+
• • • • • • •
− • − • − •
• •
• − • •
− − −

•+ •+ •+

•+ • •+ •
− −

• • ••
− •+ •+ −−

• •+ • • •+ •+ •+
− • −

• − • •
− −

•+ •+ •


That last move was trouble, as at put a “−” adjacent to a “−.” This
graph is not bipartite.

2. Matchings

Suppose we have a bipartite graph G and a particular decomposition
of the vertices into sets R and B so there are only edges from B to R.
We now will think of these as male vertices (blue) and female vertices
(pink). Let us think of the edges as indicating a possible match, were
the woman is willing to marry the man and that man is willing to
marry that woman. A marriage of such a pair we’ll call a compatible
marriage. How many compatible marriages are possible at the same
time, and how can we find such an optimal matching?

A matching, in graph theory terms, is a collection of the edges of
G so that no two edges share a vertex. If we want, we can included
the vertices involved, and then a matching is a subgraph where all the
vertices have index one.

THE MARRIAGE PROBLEM 5

For example, here’s a graph, with the men and women indicated by
color.

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

Although the theory here is a bit tricky, there is an easy algorithm that
will find us a matching with the most possible pairs.

We start by randomly picking a pair, then other pairs between un-
matched vertices:

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h
•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h
•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

THE MARRIAGE PROBLEM 6

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h
•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

We could have planned better. However, we can modify what we
have to get a better solution. While there is not edge from woman 7 to
man c, but there is a path that alternates between selected edges and
unselected edges, shown in green:

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

We now cancel all the marriages on the path and turn the other edges
in the path to marriages:

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

Back in black and white, we have a solution that must be optimal, as
it invloves all the woman:

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

THE MARRIAGE PROBLEM 7

The previous solution is not unique. Let’s run the algorithm again,
making different choices.

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

•1 •2 •3 •4 •5 •6 •7
•a •b •c •d •e •f •g •h

•1 •2 •3 •4 •5 •6 •7
•a •b •c •d •e •f •g •h

•1 •2 •3 •4 •5 •6 •7
•a •b •c •d •e •f •g •h

•1 •2 •3 •4 •5 •6 •7
•a •b •c •d •e •f •g •h

THE MARRIAGE PROBLEM 8

We can’t add another edge, so we look for an path with alternating
edges. There is one from h to 4 :

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h
Now switch marriages with non-marriages on the green path:

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

There is an alternating path from g to 2 : •6 •7
•1 •2 •3 •4 •5

•a •b •c •d •e •f •g •h
•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h

THE MARRIAGE PROBLEM 9

Removing the color green, we have our solution, different from the first
solution:

•1 •2 •3 •4 •5 •6 •7

•a •b •c •d •e •f •g •h


Click to View FlipBook Version