I am working an m_coloring problem wherein I have to determine the chromatic number m of an undirected graph using backtracking. The (java) solution I have thus far is increment m, try the m_Coloring method, and then repeat if a solution is not found. However, for the larger files, if m is over 6, the computation takes forever. I have been told that the algorithm we were given to use does not have pruning incorporated, so I am trying to figure out how to put it in and am having no luck after a week of searching.
vColor = new int[nodes+1];
vColor[1] = 1;
while(unsolved)
{
m++;
mColoring(1);
}
static void mColoring(int i)
{
int color;
if (promising(i))
{
if (i==nodes)
{
unsolved = false;
}
else
{
for(color = 1; color<=m; color++)
{
if(unsolved)
{
vColor[i+1] = color;
mColoring(i+1);
}
}
}
}
}
static public boolean promising (int i)
{
int j=1;
boolean promise = true;
while(j<i && promise)
{
if(adjMatrix[i][j] && vColor[i] == vColor[j])
{
promise = false;
}
j++;
}
return promise;
}