# Lecture 010

k-colorable: color vertex with k at most different colors so that no neighbors with the same color can be connected.

Bipartite: graph $G = \langle{V, E}\rangle$ is bipartite iff it contains no cycles of odd length. (partitioned vertex into $X, Y$ so that all edges have one endpoint in $X$ and the other in $Y$.)

• forward: odd-length cycle -> not 2-colorable -> not bipartite

• backward: BFS tree where each level is distance

Matching: a subset of edges in bipartite graph where each vertex can only appear once.

• Maximum Matching: $|M| = \min(|X|, |Y|)$

• a matching $M$ is maximum iff there is no augmenting path.
• Maximal Matching: Local Optimum

• Perfect Matching: Bijection (require $|X|=|Y|$, a graph can have no perfect matching)

Alternating (Augmenting) Path: a path alternate between $M$ and not $M$

• Augmenting Path: an alternating path such that first and last vertices are not matched by $M$. (need not contain all edges of the matching; can be size of one)

• Augmenting Path are used to invert maching to get a bigger maching set

• Theorem: a maximum match has no augmenting path (if so, then we can create larger match)

• Finding augmenting path:

• consider all connected edges from all edges, from there, color all connected edges as red and color all horizontal edge as blue. remove all uncolored edges
• then you left with every vertex has degree 1 or 2
• and red / blue alternate
• then they are either path or cycles
• then it is easy to find augmenting path there

Exercise: proof a graph with all vertices degree at most 2 is either a path or a cycle

• proof: by graph induction. pick a vertex, remove it, then by induction hypothesis, it is a path or a cycle. Put the vertex back, the vertex has degree 0, 1, or 2. In all cases, it has to be path or cycle.

• finding augmenting path is easy in Bipartite Graph, but hard in general graph. Blossom_algorithm

Hall's Theorem: Let $G = \langle{X, Y, E}\rangle$ be a bipartite. There is a matching covering all the vertices in $X$ (perfect matching) $\iff (\forall S \subseteq X)(|S| \leq |N(S)|)$ ($N$ is neighbors)

• Corollary: $G = \langle{X, Y, E}\rangle$ has a perfect matching iff $|X| = |Y| \land (\forall S \subseteq X)(|S| \leq |N(S)|)$

Application: randomly make 13 piles of 4 cards. show I can select a card from each pile to make up all 13 ranks

Stable Matching: // TODO: define

• perfect matching

• no unstable pairs

The Gale-Shapley proposal algorithm

• Theorem: Gale-Shapley algorithm always terminates with a stable matching after at most $n^2$ iterations.
• $n^2$ iterations: there are $n$ man, propose at most $n$ times.
• perfect matching: AFSOC man $m$ not matched. Either rejected by all women or being dumped out. In all cases, the women $m$ proposed will have a matching because women always have a matching after received propose. So all women are matched. So all men must be matched.
• no unstable pair: AFSOC unstable pair exists. Either $m$ never proposed to $w$ or proposed. If never, $w$ is not high in preference list. If proposed, $w$ don't have $m$ in high preference list.

Valid Partner: partners in at least one stable matching

• $\text{best}(m) = \text{highest ranked valid partner of } m$

• Theorem: Gale-Shapley returns $\{(m, \text{best}(m)) | m \in M)\}$

• Theorem: Gale-Shapley returns $\{(\text{worst}(w), w) | w \in W)\}$

Table of Content