Bipartity graph c++ : I have adjacency matrix and i wiil must check the graph on bipartion. I wrote some code, but he always return false value. Sorry for my English
Example:
INPUT
10

0 1 0 0 1 0 0 0 0 0

1 0 0 0 0 0 0 0 0 0

0 0 0 1 0 0 1 1 0 1

0 0 1 0 0 1 0 0 1 0

1 0 0 0 0 0 0 0 0 0

0 0 0 1 0 0 0 1 0 1

0 0 1 0 0 0 0 0 1 0

0 0 1 0 0 1 0 0 1 0

0 0 0 1 0 0 1 1 0 0

0 0 1 0 0 1 0 0 0 0

OUTPUT
YES
1 3 6 9


    #include <iostream>
    #include <fstream>
    #include <vector>
    #include <queue>
     
    using namespace std;
     
    bool bipartite=true;
    vector<vector<int>>g;
    vector<int>visit;
    vector<int>colour;
    int n;
     
    void dfs(int v)
    {
        visit[v] = 1;
        if (colour[v] == 0)
        {
            colour[v] = 1;
        }
        for (int i = 0; i < g[v].size(); i++)
        {
            if (visit[i] == 0)
            {
                if (colour[v] == 1)
                {
                    colour[i] = 2;
                }
                else
                    colour[i] = 1;
                dfs(i);
            }       
            if (visit[i] == 1 && colour[i] == colour[v])
                bipartite = false;
        }
        
    }
     
    int main()
    {
        ifstream fin("input.in");
        ofstream fout("output.out");
        int a;
     
        fin >> n;
        g.resize(n);    
        visit.resize(n);
        colour.resize(n);   
     
        for (int i = 0; i < g.size(); i++)
        {       
            for (int j = 0; j < n; j++)
            {
                fin >> a;           
                g[i].push_back(a);
            }
        }
        
        for (int i = 0; i < n; i++)
        {       
            if (visit[i] == 0)
                dfs(i);
        }
        
        cout << bipartite;
     
        return 0;
    }