Mohamed G. Gouda CS 313K Fall 2012 Exercise 6 1. How to prove that a graph G=(V,E) is bipartite? And how to prove that it is not bipartite? Sol: To prove that G=(V,E) is bipartite, exhibit a partitioning V1 and V2 of V such that for every edge (u1,u2) in E, u1 is in V1 and u2 is in V2. To prove that G=(V,E) is not bipartite, exhibit a cycle of odd length in G 2. Which of the following two graphs is bipartite and which of them is not. (a) G1 = (V1,E1) where V1 = {1,2,3,4}, E1 = {(1,2),(2,3),(2,4),(3,4),(4,1)} (b) G2 = (V2,E2) where V2 = {1,2,3,4,5} E2 = {(1,2),(2,3),(2,5),(3,4),(4,1),(5,4)} Sol: (a) G1 is not bipartite because it has a cycle (1,2,4,1) of odd length (b) G2 is bipartitle because its vertices can be partitioned into two partitions {1,3,5} and {2,4} 3. Use a direct inference proof to show that (TR is tree) => (TR is bipartite) Sol: (TR is tree) => {definition of Tree} (TR is connected and has no simple circuits) => {Every cycle is a simple circuit} (TR has no cycles) => {prperty of All with empty domains} (All cycles in TR are of even length) => {Theorem of Bipartite Graphs} (TR is bipartite) 4. Give an example graph that is a bipartite but not a tree. Sol: An example graph is G=(V,E) where V={1,2,3,4} E={(1,2),(2,3),(3,4),(4,1)} G consists of a single cycle of even length. Thus, G is a bipartite and not a tree. 5. Let G be a graph that consists of two connected components G1 and G2. Give a two-sided inference proof that shows (G is bipartite) <=> (G1 is bipartite) and (G2 is bipartite) Sol: (G is bipartite) <=> {Theorem of Bipartite Graphs} (every cycle in G is of even length) <=> {definition of components} (every cycle in G1 is of even length) and (every cycle in G2 is of even length) <=> {Theorem of Bipartite Graphs} (G1 is bipartite) and (G2 is bipartite) 6. Let G be a graph that consists of k connected components and let these components have n.1, n.2, ..., n.k vertices. Show that the number of edges in G is at most (sum over i, 1 =< i =< k, n.i(n.i-1)/2) Sol: The number of edges in G is maximum iff for every i, 1 =< i =< k, the i-th component in G is a complete graph with n.i vertices. Thus, the number of edges in G is maximum iff for every i, 1 =< i =< k, the i-th component in G has n.i(n.i - 1)/2 edges. Thus, the number of edges in G is at most (sum over i, 1 =< i =< k, n.i(n.i-1)/2) 7. Write an algorithm that takes a graph G as input and computes a 2-coloring of G such that the computed 2-coloring is valid iff input G is 2-colorable. Sol: The required algorithm consists of three steps. Step 1: Color Black any vertex v in G Step 2: Color Black every vertex whose shortest distance from v is even Step 3: Color White every vertex whose shortest distance from v is odd 8. Let G be a graph. Show, by contradiction, that if G has exactly two vertices u1 and u2 whose degrees are odd, then G has a path between u1 and u2. Sol: (G has exactly two vertices u1 and u2 whose degrees are odd) and (G has no path between u1 and u2) => {definition of components} (G has exactly two vertices u1 and u2 whose degrees are odd) and (G has two components G1 and G2 such that u1 is in G1 and u2 is in G2) => {only u1 and u2 have odd degrees in G} (u1 is the only vertex whose degree is odd in G1) => {Corollary 2 of Handshake Theorem} F 9. Let G be a graph where max-deg(G) =< 3. Show, by contradiction, that every simple circuit in G is a cycle. Sol: (max-deg(G) =< 3) and (G has a simple circuit that is not a cycle) => {no cycle has repeated vertices} (this simple circuit has a repeated vertex v and it is of the form (u, ..., a, v, b, ..., x, v, y, ..., u)) => {every simple circuit has no repeated edges} (in this simple circuit, the four edges (a,v), (v,b), (x,v), (v,y) are all distinct) => {definition of deg(v)} (deg(v)=4) => {definition of max-deg(G)} (max-deg(G) >= 4 and max-deg(G) =< 3) => F