Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

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

For each node in an undirected graph, let twodegreeube the sum of the degrees of’s neighbors. Show how to compute the entire array of two degree. values in linear time, given a graph in adjacency list format

Design a linear-time algorithm which, given an undirected graph G and a particular edge ein it, determines whetherGhas a cycle containing.

Infinite paths.Let G=(V,E) be a directed graph with a designated “start vertex” sV,asetVGV, a set of “good” vertices, and a set VBV of “bad” vertices. An infinite trace of is an infinite sequence of vertices viV such that (1)v0=s, and (2) for all i0, (vi,vi+1)E. That is, p is an infinite path in G starting at vertex s. Since the setV of vertices is finite, every infinite trace of Gmust visit some vertices infinitely often.

  1. If p is an infinite trace, let Inf(p)V be the set of vertices that occur infinitely often in p. Show that Inf(p) is a subset of a strongly connected component of G.
  2. Describe an algorithm that determines if role="math" G has an infinite trace.
  3. Describe an algorithm that determines if G has an infinite trace that visits some good vertex in VG infinitely often.
  4. Describe an algorithm that determines if role="math" localid="1659627728759" G has an infinite trace that visits some good vertex in VG infinitely often, but visits no bad vertex in VB infinitely often.

Give a linear-time algorithm for the following task.
Input: A directed acyclic graph G

Does G contain a directed path that touches every vertex exactly once?

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?

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