
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% General description:
%
% This function find set of feasible colors for the i-th vertex that can 
% be assigned
%
% input:
%       G(n,n) - The whole graph. If G(i,j)=1, then (i,j) is an edge
%       colors - array of colors of colored vertices.
%       k - The maximum color can be used 
%       i - This function is to find feasible colors for the i-th vertex 
%       len - The size of feasible set 
%
% output: 
%       FCi(len,1) - Set of feasible colors for the i-th vertex
%
% Written by: Wei Wang
% Machine Learning for Signal Processing Lab
% University of Maryland, Baltimore County
% 8/21/2007
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


function [FCi] = findFeasibleColors(G, colors, k, i, len)

n=size(G,1);
adjcolors=[];
for j=1:i-1
    Nj=find(G(j,:)>0);
    if numel(intersect(i,Nj))==1
        adjcolors=[adjcolors colors(j)];
    end
end

ubC=max(colors); % maximum color used prior to i
t=[1:min(ubC+1,k)];
t(adjcolors)=[];
nt=numel(t);

FCi=[t zeros(1,len-nt)];

