I have been trying to understand the bipartite graph. To my understanding it is a graph G which can be divided into two subgraphs U and V.So that intersection of U and V is
The following is a BFS approach to check whether the graph is bipartite.
c = 0
x
and set x.class = c
ys
be the nodes obtained by BFS
c = 1-c
y
in ys
set y.class = c
y
in ys
has a neighbour z
with z.class == c
then the graph is not bipartiteThis assumes that the graph is a single connected component -- if it is not, simply do this procedure for each component.