(a) Assume
G
is bipartite and let the vertex partition be
V
1
,
V
2
.
Let
C
be a cycle
i
1
,
· · ·
, i
k
, i
k
+1
=
i
1
and let say that
i
1
∈
V
1
, then every oddindexed vertex
in
C
is also in
V
1
, and every evenindexed vertex is in
V
2
. Therefore,
k
+ 1 must be odd, so
k
is even, but
k
is the length of cycle
C
.
(b) Assume the graph is connected. If it is not connected, then we apply the following algorithm
to each connected component. The idea of the algorithm is as follows:
Initially, we color all vertices white and pick any vertex s as starting vertex, color it red,
and perform a breadthﬁrst search on the graph. When a vertex is ﬁrst encountered (i.e. it is
now in white), color it blue if the BFS has just come from a red node, and red otherwise. If
at any point, the breadthﬁrst search encounters an edge between two vertices with identical
colors, then the graph is not bipartite; otherwise, it is. The pseudocode of the algorithm is
shown below.
ToggleColor(c) {
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '10
 may
 English, Graph Theory, Bipartite graph

Click to edit the document details