public static boolean isBipartite(int[][] adj, int src){
        int V = adj.length;
        int[] colors = new int[V];
        for(int i = 0; i < V; i++) colors[i] = -1;

        Queue<Integer> queue = new LinkedList<Integer>();
        queue.offer(src);
        colors[src] = 1;

        while(queue.isEmpty()){
            int u = queue.poll();

            for(int v = 0; v < V; v++){
                if(adj[u][v] == 1){
                    if(colors[v] == -1){
                        colors[v] = 1 - colors[u];
                    }else if(adj[u][v] == colors[u]){
                        return false;
                    }
                }
            }
        }
        return true;
    }