function [Test,Train]=Snowball(cora_cites,k,Fraction)
%% Definition
%computing the number of test objects
Nodes=unique(cora_cites);
n_train= floor(size(Nodes,1).* Fraction);
Test=zeros(n_train,k);
Train=zeros(size(Nodes,1)-n_train,k);
% n_seed=floor(n_train*0.02);
n_seed=1;
%% repeat k times
for i = 1 : k
    Seed=unique(cora_cites(randi(size(cora_cites,1),[n_seed,1]),1));
    Selected=Seed;
    while size(Selected,1)< n_train
        % Finding the unselected Neighbors of seed nods
        tmp_Neighbor=(ismember(cora_cites(:,1),Seed) & ~ismember(cora_cites(:,2),Selected));
        Neighbor=unique(cora_cites(tmp_Neighbor,2));
        % Randomly selecting the neighors
        tmp_Selected=[];
        if ~isempty(Neighbor)
            tmp_Selected=Neighbor(rand(size(Neighbor,1),1)<=(Fraction/2));
        end
        % if none of the neighbors are selected a new set of seeds should
        % be selected to continue 
        if isempty(tmp_Selected)
           Seed=unique(cora_cites(randi(size(cora_cites,1),[n_seed,1]),1));
        else
        % when at least one neighbors is selected they will be added to the
        % selected nodes and the seeds set will be updated
           Selected=[Selected;tmp_Selected];
           Seed=tmp_Selected;
        end
    end
    Test(:,i)= Selected(1:n_train);
    tmp_Train=Nodes;
    tmp_Train(ismember(Nodes,Test(:,i)))=[];
    Train(:,i)=tmp_Train;
end
return