What is wrong in this code for m coloring problem

public static boolean graphColoring(List[] G, int[] colo, int i, int C)
{
int color[] = new int[G.length+1];

    int N = G.length;
    int M = C;
    
    boolean[]visited = new boolean[N+1];
    for(int j=0 ; j<N ; j++)
    {
        if(visited[j]==false)   
            colour(G , color , M , j , visited) ;
    }
    
    int max=0;
    for(int j=1 ; j<color.length ; j++)
    {
        System.out.print(color[j]+" ");
        if(max<color[j])
            max = color[j];
    }
    
    System.out.println();
    //System.out.println(max+" "+M+" "+N);
    if(max>M) return false;
    return true;
}


public static void colour(List<Integer>[] graph , int[]color , int M , int i , boolean[]visited)
{
    if(visited[i]) return;
    visited[i] = true;
    
    boolean temp[] = new boolean[graph.length+1];
    for(int j : graph[i])
        temp[color[j]] = true;
    
    int j=1;
    for(j=1 ; j<=graph.length ; j++)
        if(temp[j]==false)
            break;

    color[i+1] = j;
    
    for(int k : graph[i])
        colour(graph , color , M , k , visited);
    
}

can you explain my mistake in the code ?

this is the link to question

https://practice.geeksforgeeks.org/problems/m-coloring-problem/0

hi.
refer this https://ide.codingblocks.com/s/578065

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

can you explain what have you done ?

and also let me know mistake in my code as well !

Initially i have maintained a color array in which all nodes are assigned color 0. then i am recursively assigning each color from 1 to m and checking if it is possible or not using backtracking. if yes then ans is true else false


u can read this article for further reference.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.