Question: ( 5 pts . ) Determining if a graph is bipar te . A graph G = ( V , E ) is bipar te

(5 pts.) Determining if a graph is biparte. A graph G =(V, E) is biparte if its verces
can be paroned into two sets V1 and V2(i.e., V = V1\cup V2 and V1\cap V2=) so that
every edge has one endpoint in V1 and another endpoint in V2. Equivalently, G is biparte
if its verces can be colored red or blue so that every edge has one red endpoint and one
blue endpoint. (V1 consists of the red verces while V2 the blue verces.) Many real-world
problems are modeled by biparte graphs for example, when matching employees to jobs,
V1 can represent the set of all employees, V2 the set of all jobs and there is an edge from an
employee to a job if the employee is qualified for the job.
a.(1 pt.) Explain why an odd cycle (i.e. a cycle of odd length) is not biparte, and
why a graph that has an odd cycle as a subgraph is not biparte.
Heres a standard way of determining if a given connected graph G is biparte: Starng at
some arbitrary node s, run BFS(G, s). Addionally record each node vs layer in the tree
as v.layer. (That is, if v in Li then v.layer = i.) When BFS(G, s) ends, go through every
edge. If some edge e = uv is a cross edge and u.layer = v.layer, return G is not a
biparte graph. Otherwise, if every cross edge does not sasfy this condion, return G is
a biparte graph.
b.(2 pts.) Explain why the above algorithm is correct. That is, argue that when the
algorithm returns G is not a biparte graph then G is indeed not a biparte graph.
On the other hand, when the algorithm returns G is a biparte graph then explain
why G is indeed a biparte graph. That is, which verces should go to V1 and which
verces to V2?
c.(2 pts.) It is not difficult to check that the above algorithm runs in linear me (i.e.
O(n + m)me). This me around, describe a linear me algorithm that checks if a
connected graph is biparte or not based on DFS. Please explain why your algorithm
is correct and why it runs in linear me

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!