to check if a given connected graph is a bipartite graph