What a bipartite graph:-
A bipartite graph (or bigraph) is a graph whose vertices can be divided into two disjoint and independent sets U and V such that every edge connects a vertex in U to one in V. Vertex sets U and V are usually called the parts of the graph.
here we take a colour array in which we store the colour in form of 1 and 0 .if colour of parent and child is same then the graph is not a bipartite graph.
in the code I use c^1 (c xor 1) that means if c have 1 then after xor operation it become 0 and if 0 then it become 1
// Bipartite graph
using namespace std;
// array for colour
// function for dfs
bool dfs(int v,int c)
printf(“Enter number vertex and number of edgesn”);
cout<<“Enter all the edges”<<endl;
cout<<“Not a Bipartite graph”;
for the graph
since is a bipartite graph. so let’s check by the code
Enter the number of vertex and edges
Enter all edges