Graph 3
Graph 3
• Bipartite Graphs.
A graph G = (V, E) is bipartite if there is partition of V = L ∪ R such that L ∩ R = ∅ and for every
edge e = (u, v) ∈ R, we have |{u, v} ∩ L| = |{u, v} ∩ R| = 1. That is, every edge has exactly one
endpoint in L and exactly one endpoint in R.
Remark: Note this means that for any two vertices in L, there are no edges between them. For
any two vertices in R, there are no edges between them.
A bipartite graph is often written with the explicit partition, that is, it is often written as G = (L∪R, E)
which shows the partition of the vertex set into L and R.
• Why? Bipartite graphs are very useful objects to denote relations between two classes of objects:
agents-items, jobs-machines, students-courses, etc.
For example, suppose we have a set of students and a set of offered classes. Each student wants to take
a certain subset of classes. All this can be captured in a bipartite graph. Let S be the set of students
and C be the set of classes. Consider the graph G = (S ∪ C, E) (it is bipartite by the notation), where
we have an edge from a student s ∈ S to a class c ∈ C if s wants to be in the class c.
It is also an important class of graphs in that some problems (and we will see one of them soon) is just
easier to solve on bipartite graphs. Thus, it would be nice to know when a given graph G = (V, E) is
indeed bipartite. The following theorem shows a characterization.
• Characterization.
Remark: Before we prove the above theorem, let me give a philosophical interpretation of this,
which is actually pretty deep. Let’s see if something gets across.
Imagine an all powerful person, let us call them Prover who just knows whether or not a graph
G is bipartite or not. So, if we have a graph G, we can go to Prover and get the answer. But we
Verifiers are skeptics; we need a reason as well for the answer. A reason we can verify. So we ask
Prover, “Hey, give me some evidence for your answer.” Now let us wonder what evidence Prover
can give.
If G was indeed bipartite, then Prover explicitly tells us what the partition L and R is. Then we
as Verifiers can go over edges of our graph G and check that exactly one end point lies in the
part L and the other in the other part R. And then we will be convinced.
But what if G is not bipartite? Naively, Prover would have to go over all partitions L ∪ R, and for
each of them exhibit an edge (u, v) whose both endpoints lie in L or R. There are 2n partitions of
1
Lecture notes by Deeparnab Chakrabarty. Last modified : 28th Aug, 2021
These have not gone through scrutiny and may contain errors. If you find any, or have any other comments, please email me at
[email protected]. Highly appreciated!
1
an n-vertex graph (right?). Reading and verifying this evidence, for a 1000 vertex graph, would
take us centuries. So no, not satisfactory.
Here is where the above characterization helps! The above theorem asserts that if G is not
bipartite, then G must have an odd-length cycle C. This is what Prover gives us. Upon receiving,
we check that the cycle indeed is present in G, and then we are convinced that indeed G is not
bipartite (see Lemma 1). And all is good.
All the stuff above might seem like a fun(?) story, but there are actual real-world parallels
today. Most computing is done on the cloud today by some entities who have lot of compute
power (Provers), and we verifiers send this to them. However, they also must send us back
proofs/evidence. If we sent them some data to do some analytics, they should also give us reasons
for their various hypothesis. As of today, most of them don’t. And, well, it is a big issue. This
forms one part of the burgeoning area called “Interpretable AI”.
Ok enough of a digression, moving to stuff we can prove.
We prove this theorem, piece by piece, over three lemmas. The first is a necessary condition
Proof. Suppose, for contradiction’s sake, G is bipartite. That is, there exists disjoint subsets L and R
such that V (G) = L ∪ R and every edge (u, v) ∈ E(G) has one endpoint in L and one endpoint in
R.
Now, let C = (x1 , x2 , . . . , x2k , x2k+1 ) be the odd cycle, for some k ≥ 1. The first vertex x1 lies in L
or R. Without loss of generality assume x1 ∈ L (otherwise swap the names of L and R). This implies
x2 ∈ R since (x1 , x2 ) ∈ E, x3 ∈ L, x4 ∈ R, and so on. More generally, x2i+1 ∈ L and x2i ∈ R
for any natural i. But this leads to x2k+1 ∈ L. This is a contradiction since (x2k+1 , x1 ) ∈ E(G), and
x1 ∈ L as well.
So we have shown that if a graph G contains an odd cycle, it is not bipartite. The more interesting
direction is to prove if G does not contain an odd cycle, then it must be bipartite. To do so, first we
consider the case of graphs with no cycles (that is, forests). Clearly, a graph with no cycles contains
no odd cycles. The fact better be true for these.
Proof. We prove the lemma by induction on the number of vertices. Let P (n) be the predicate
which takes the value true if every forest G = (V, E) with |V | = n is bipartite. We wish to show
∀n ∈ N : P (n) is true.
Base Case: P (1) is true. Indeed any graph with 1 vertex (and therefore no edges) is bipartite trivially;
L = V, R = ∅.
Inductive Case: Fix a natural number k, and assume P (k) is true. We need to show P (k + 1) is
true. Once again, this means every forest on k vertices is bipartite, and we need to prove every forest
on (k + 1)-vertices is bipartite. To this end, fix a forest G = (V, E) with |V | = k + 1. We know
from the previous lectures that there must exist a v ∈ V with degG (v) ≤ 1. Consider the graph
2
G0 = G − v. Note two things. One, G0 is a forest since deleting an edge cannot introduce cycles.
Two, |E(G0 )| ≥ |E(G0 )| − 1 since degG (v) ≤ 1.
Since |V (G0 )| = k and G0 is a forest, by the induction hypothesis we get G0 is bipartite. That is, there
exists a partition L ∪ R of V (G0 ) such that for any edge (x, y) ∈ E(G0 ), both x and y are not in the
same partition. If degG (v) = 0, add v arbitrarily to any part. If degG (v) = 1 and if (u, v) ∈ E(G)
is the unique edge incident to v in G, then if u ∈ L add v to R, and otherwise add v to L. This is a
valid bipartition of the vertices of G. This prove P (k + 1) is true, and by induction the statement is
true.
Good, at least graphs with no cycles are bipartite. Now we have all the ingredients for the proof of
Theorem 1.
Proof of Theorem 1. We proceed to prove this by induction as well. To this end, let P (m) be the
predicate which takes the value true if any graph with exactly m edges and no odd cycles is bipartite.
We need to show that ∀m ∈ N : P (m) is true.
Base case: We prove P (1) is true. Let G be an arbitrary graph with |E(G)| = 1. Let this edge
by (x, y). Then, let L = {y} and R = V (G) \ y. Since every edge of G (there is only one) has
exactly one end point in L and the other in R, this proves G is bipartite. (PS: We also could have
just used Lemma 2 since a graph with one edge must be a forest.)
Inductive Case: Let k ≥ 1 and assume that P (k) is true. We need to show P (k + 1) is true. To
this end, fix an arbitrary graph G = (V, E) with no odd cycles and with |E| = k + 1.
If G has no cycles, then by Lemma 2, G is bipartite. Therefore, henceforth we assume that G
has at least one cycle. Let C := (u1 , . . . , u` , u1 ) be any cycle in G. Note ` must be even.
Now consider the graph G0 = G − (u` , u1 ) formed by deleting a single edge. All cycles in
G0 have even length (since all cycles in G have even length and no new cycles have been in-
troduced), and |E(G0 )| = k. So, by the induction hypothesis, G0 is bipartite. Let (L, R) be a
bipartition of G0 .
Now, note that (u1 , . . . , u` ) is a path in G0 . Without loss of generality assume u1 ∈ L (otherwise
swap the names). Therefore, we get u2 ∈ R, u3 ∈ L, and so on, more generally, u2i+1 ∈ L and
u2i ∈ R. In particular, u` ∈ R since ` is even.
Therefore, (L, R) is also a bipartition of G. Indeed, (u1 , u` ) satisfies the bipartition condition.
And so does every edge e ∈ E(G0 ). Thus G is bipartite implying P (k + 1) is true.