ta4sol - (a) Assume G is bipartite and let the vertex...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
(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 odd-indexed vertex in C is also in V 1 , and every even-indexed 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-first search on the graph. When a vertex is first 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-first search encounters an edge between two vertices with identical colors, then the graph is not bipartite; otherwise, it is. The pseudo-code of the algorithm is shown below. ToggleColor(c) {
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/09/2010 for the course ENGLISH 1303 taught by Professor May during the Spring '10 term at HKU.

Page1 / 2

ta4sol - (a) Assume G is bipartite and let the vertex...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online