function figure_graph_color(adj,vertices, f)
%
% figure_graph_color(adj,vertices, f)
% 
% it colors a graph (adj matrix) with given value f.
% 
% adj     : adjacency matrix consisting of 0 and 1.
% vertices: node coordinates in a matrix form
% f       : function value on a node
%
% 
%
% (c) Moo K. Chung 
%     mkchung@wisc.edu
%     Univeristy of Wisconsin
%
% October 12, 2009; Febuary 25, 2010;
% July 10, 2010: A new argument edgecolor is introduced. 


% uncomment to draw edges. 

hold on;
%

if size(vertices,2)==2 %2D case
    hold on;
    scatter(vertices(:,1),vertices(:,2), 50, f,'filled')


    for i=1:size(vertices,1)
        hold on;
        %     scatter3(vertices(i,1),vertices(i,2),vertices(i,3), degree, degree) %'.r');

        % uncomment line below to remove node indexing in figure
        %text(vertices(i,1)+0.5,vertices(i,2)+0.5,vertices(i,3)+0.5,num2str(i),'Color','k');
    end;

    k=1;
    for i=1:size(vertices,1)
        for j=1:size(vertices,1)
            if adj(i,j)==1
                hold on;
                %pause;

                plot(vertices([i j],1),vertices([i j],2),'-c','LineWidth',1, 'Color',[.5 .5 .5]);
                %axis equal
                % uncomment to get a movie
                M(k) = getframe;
                k=k+1;
            end;
        end;
    end;

    hold on;

    % 4th argument 10*f is the radius of a ball we are drawing. this is not the
    % actual radius of the ball in mm but rather MATLAB convention.
    % The size of balls are proportional to the color scheme.
  


else %3D case
    
    % 4th argument is the radius of a ball we are drawing. this is not the
    % actual radius of the ball in mm but rather MATLAB convention.
    % The size of balls are proportional to the color scheme.
    % 5th argument is color
    
    %scatter3(vertices(:,1),vertices(:,2),vertices(:,3), 2*f, 'r','filled')
  scatter3(vertices(:,1),vertices(:,2),vertices(:,3), f/5, f,'filled')
  

    for i=1:size(vertices,1)
        for j=1:size(vertices,1)
            if adj(i,j)>0
                hold on;
                %pause;

                %plot3(vertices([i j],1),vertices([i j],2),vertices([i j],3),'-c','LineWidth',1, 'Color',[.3 .3 .7]);
               plot3(vertices([i j],1),vertices([i j],2),vertices([i j],3),'-c','LineWidth',1, 'Color', 'k');
            end;
        end;
    end;




    for i=1:size(vertices,1)
        hold on;
        %     scatter3(vertices(i,1),vertices(i,2),vertices(i,3), degree, degree) %'.r');

        % uncomment line below to remove node indexing in figure
        %text(vertices(i,1)+0.5,vertices(i,2)+0.5,vertices(i,3)+0.5,num2str(i),'Color','k');
    end;


end;




set(gcf,'Color','white','InvertHardcopy','off');



