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

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.

Question:Undirected vs. directed connectivity.

(a) Prove that in any connected undirected graph G =(V , E)there is a vertexvโˆˆV 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 everyvโˆˆV, 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.

Infinite paths.Let G=(V,E) be a directed graph with a designated โ€œstart vertexโ€ sโˆˆV,asetVGโŠ†V, a set of โ€œgoodโ€ vertices, and a set VBโŠ†V of โ€œbadโ€ vertices. An infinite trace of is an infinite sequence of vertices viโˆˆV such that (1)v0=s, and (2) for all iโ‰ฅ0, (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 an efficient algorithm that takes as input a directed acyclic graph G=V,E, and two vertices s,tโˆˆV, and outputs the number of different directed paths from S to t in G.

You are given a directed graph in which each nodeuโˆˆV, has an associated pricepu which is a positive integer. Define the array cost as follows: for each uโˆˆV,

cost[u] = price of the cheapest node reachable fromu (includingu itself).

For instance, in the graph below (with prices shown for each vertex), the cost values of the nodes A,B,C,D,E,Fare2,1,4,1,4,5,respectively.

Your goal is to design an algorithm that fills in the entire cost array (i.e., for all vertices).

(a) Give a linear-time algorithm that works for directed acyclic graphs.

(b) Extend this to a linear-time algorithm that works for all directed graphs.

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