A bipartite graph is a graph G=(V,E)whose vertices can be partitioned into two sets (V=V1V2andV1V2=ϕ) such that there are no edges between vertices in the same set (for instance, if , then there is no edge between and ).

(a) Give a linear-time algorithm to determine whether an undirected graph is bipartite.

(b) There are many other ways to formulate this property. For instance, an undirected graph is bipartite if and only if it can be colored with just two colors. Prove the following formulation:

an undirected graph is bipartite if and only if it contains no cycles of odd length.

(c) At most how many colors are needed to color in an undirected graph with exactly one odd length?

Short Answer

Expert verified

(a) A linear-time algorithm to determine whether an undirected graph is bipartite is proved.

(b) An undirected graph is bipartite if and only if it is colored with just two colors. An undirected graph is bipartite if and only if it contains no cycles of odd length is proved.

(c) At most three colors are needed to color in an undirected graph with exactly one odd length.

Step by step solution

01

Explain Bipartite graph.

Bipartite graph is a graph G whose vertices are and v where all nodes of graphis connected itself or is not connected with any other node in a same graph as well as with graph . The vertices ofu are connected by vertices of vbut the nodes of these graph are not connected with any node of its own graph is known as bipartite graph.

A bipartite graph is defined as a graph where each vertex of its own set are never connected with each other. It must be connected by to the vertices of the different set of the graph.

02

Define a linear time algorithm to determine whether an undirected graph is bipartite.

a)

Following is the linear time algorithm to check if an undirected graph is bipartite:

1). Consider graph G which contain two sets of graphs named as u and v .

2). Take red color node as a source vertex and put this vertex in a set u . Then, color all the vertices blue which are directly connected to the source vertex and put these vertices to another set named v .

3). The blue vertex is connected with other node, color it red and put into the set of u graph.

4). The vertices of blue color and the vertices are in red color are not directly connected to each other. It means take all vertices of graph u is in the Red color and all vertices of graph v is in blue color.

5). Like that, assign red and blue color to all vertices and it satisfies all the constraints of m way coloring problem in which m = 2 .

Fig 1: Bipartite graph

03

Prove (b)

(b)

An undirected graph is bipartite if and only if it contains no cycles of odd length or if it contains cycle of even length then only it is bipartite graph. In the diagram shown in fig 2 , there are 0,1,2,3,4,5,6 some edges they are 0,1,2,3,4,5,6. If 0 is the source vertex so color it red from 0 the two nodes are connected they are one and three color these both vertex with blue color. Now, look at the vertex 1 and 3 if any edge is connected to 1 and 3 then color it red.

From 1 again two edges are connected: they are 4 and 5 .So color these by blue color and again search the next node is 2 . Check whether it is connected to any red colored node or not, if no then color it red. Apply this method for each vertex and now the remaining vertex is 6 , which is connected by both 4 and 5 . Both 4 and 5 are colored with blue. Then, color the vertex as red. Through this it shows that the undirected graph is bipartite.

Fig:2 Showing undirected bipartite graph.


Fig:3 Showing undirected bipartite graph.

04

Find the number of colors needed in odd length cycle.

c)

The number of colorsneeded to color in an undirected graph with exactly one odd length is three because if the number of vertices is odd then the number of colors required is three. If the number of vertices is even then the number of colors required is two.

Hence, if number of vertices are odd then the number of colors required is three.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

In an undirected graph, the degreed(u) of a vertex u is the number of neighbours u is the number of neighbors u has, or equivalently, the number of edges incident upon it. In a directed graph, we distinguish between the indegreedin(u), which is the number of edges into u, and the outdegreedout(u), the number of the edges leaving u.

(a) Show that in an undirected graph, role="math" localid="1658908755010" uevd(u)=2|E|

(b) Use part (a) to show that in an undirected graph, there must be an even number of vertices whose degree is odd.

(c) Does a similar statement hold for the number of vertices with odd indegree in a directed graph?

In the 2SAT problem, you are given a set of clauses, where each clause is the disjunction (OR) of two literals (a literal is a Boolean variable of or the negation of a Boolean variable). You are looking for a way to assign a valuetrueorfalseto each of the variables so that all clauses are satisfied- that is, there is at least one true literal in each clause. For example, here’s an instance of 2SAT:

x1x2¯x1¯x3¯x1x2x3¯x4x1¯x4

This instance has a satisfying assignment: set x1,x2,x3, and x4 totrue, false, false,andtrue,respectively.

  1. Are there other satisfying truth assignments of this 2SAT formula? If so, find them all.
  2. Give an instance of 2SAT with four variables, and with no satisfying assignment.

The purpose of this problem is to lead you to a way of solving 2SAT efficiently by reducing it to the problem of finding the strongly connected components of a directed graph. Given an instance l of 2SAT with n variables and m clauses, construct a directed graph GI=V,E as follows.

  • GIhas 2nnodes, one for each variable and its negation.
  • GIhas 2m edges: for each clause αβof l (where α,βare literals), G1has an edge from the negation of α to β, and one from the negation ofβ to α.

Note that the clause αβis equivalent to either of the implications α¯β or β¯α. In this sense, data-custom-editor="chemistry" GI records all implications in l .

(C). Carry out this construction for the instance of 2SAT given above, and for the instance you constructed in (b).

(d). Show that if GI has a strongly connected component containing both x and X¯ for some variable x , then l has no satisfying assignment.

(e). Now show the converse of (d): namely, that if none of GI’s strongly connected components contain both a literal and its negation, then the instance l must be satisfiable.(Hint: Assign values to the variables as follows: repeatedly pick a sink strongly connected component of GI. Assign valuetrueto all literals in the sink, assignfalseto their negations, and delete all of these. Show that this ends up discovering a satisfying assignment.)

(f). Conclude that there is a linear-time algorithm for solving 2SAT.

Give a linear-time algorithm to find an odd-length cycle in a directed graph. (Hint: First solve this problem under the assumption that the graph is strongly connected.)

Question:Undirected vs. directed connectivity.

(a) Prove that in any connected undirected graph G =(V , E)there is a vertexvV whose removal leaves G connected. (Hint: Consider the DFS search tree for G.)

(b) Give an example of a strongly connected directed graph G(V ,E)such that, for everyvV, removing v from G leaves a directed graph that is not strongly connected.

(c) In an undirected graph with two connected components it is always possible to make the graph connected by adding only one edge. Give an example of a directed graph with two strongly connected components 0 such that no addition of one edge can make the graph strongly connected.

Two paths in a graph are called edge-disjointif they have no edges in common. Show that in any undirected graph, it is possible to pair up the vertices of odd degree and find paths between each such pair so that all these paths are edge-disjoint.

See all solutions

Recommended explanations on Computer Science Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free