private boolean backtraking()

in src/main/java/org/apache/commons/graph/coloring/DefaultColoringAlgorithmsSelector.java [154:180]


    private boolean backtraking( int currentVertexIndex, List<V> verticesList, ColoredVertices<V, C> coloredVertices )
    {
        if ( currentVertexIndex != -1
                        && isThereColorConflict( verticesList.get( currentVertexIndex ), coloredVertices ) )
        {
            return false;
        }

        if ( currentVertexIndex == verticesList.size() - 1 )
        {
            return true;
        }

        int next = currentVertexIndex + 1;
        V nextVertex = verticesList.get( next );
        for ( C color : colors )
        {
            coloredVertices.addColor( nextVertex, color );
            boolean isDone = backtraking( next, verticesList, coloredVertices );
            if ( isDone )
            {
                return true;
            }
        }
        coloredVertices.removeColor( nextVertex );
        return false;
    }