#### Bipartite Grapf DFS

A
```package com.thealgorithms.datastructures.graphs;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;

/**
* Given an adjacency list of a graph adj of V no. of vertices having 0 based
* index. Check whether the graph is bipartite or not.
*
* Input : {{0, 1, 0, 1}, {1, 0, 1, 0}, {0, 1, 0, 1}, {1, 0, 1, 0}}
*
* Output : YES
*/
public final class BipartiteGrapfDFS {
private BipartiteGrapfDFS() {
}

private static boolean bipartite(int v, ArrayList<ArrayList<Integer>> adj, int[] color, int node) {
if (color[node] == -1) {
color[node] = 1;
}
for (Integer it : adj.get(node)) {
if (color[it] == -1) {
color[it] = 1 - color[node];
if (!bipartite(v, adj, color, it)) {
return false;
}
} else if (color[it] == color[node]) {
return false;
}
}
return true;
}

public static boolean isBipartite(int v, ArrayList<ArrayList<Integer>> adj) {
// Code here
int[] color = new int[v + 1];
Arrays.fill(color, -1);

for (int i = 0; i < v; i++) {
if (color[i] == -1) {
if (!bipartite(v, adj, color, i)) {
return false;
}
}
}
return true;
}

public static void main(String[] args) throws IOException {
while (t-- > 0) {
int numVertices = Integer.parseInt(str1[0]);
int numEdges = Integer.parseInt(str1[1]);

ArrayList<ArrayList<Integer>> adj = new ArrayList<>();
for (int i = 0; i < numVertices; i++) {
}
for (int i = 0; i < numEdges; i++) {
int vertexU = Integer.parseInt(str2[0]);
int vertexV = Integer.parseInt(str2[1]);