function [G, score_sort,G_possible] = most_violated_cliques_v_test(alpha_Y, prob,Y,Y_mod,B_)
%%find the most-violated clique (edge)
%Y_mod store the label identified by previous iterations
B = B_;
G_possible = prob.G_possible;
N_inst = prob.num_inst;
num_possible_edge = size(G_possible,1);

%If there are n nodes, then there are n(n-1)/2 edges in total.


for i=1:1:num_possible_edge
Y_expend = zeros(N_inst,4);%*num_possible_edge
Y_Node1 = Y(:,G_possible(i,1));
Y_Node2 = Y(:,G_possible(i,2));
Y_pos = 2*Y_Node1 + Y_Node2 +1; %+ repmat(Idx,N_inst,1)
t1=cell2mat(arrayfun(@(x) (Y_pos(x,:) - 1) * N_inst + x, 1:N_inst, 'UniformOutput', 0));
Y_expend(t1)  = 1;

Y_mod_expend = zeros(N_inst,4);
Y_Node1 = Y_mod(:,G_possible(i,1));
Y_Node2 = Y_mod(:,G_possible(i,2));
Y_mod_pos = 2*Y_Node1 + Y_Node2 +1;
t1=cell2mat(arrayfun(@(x) (Y_mod_pos(x,:) - 1) * N_inst + x, 1:N_inst, 'UniformOutput', 0));
Y_mod_expend(t1)  = 1;
Y_Diff = Y_expend - Y_mod_expend;
alpha_Y_dot_Diff = alpha_Y'*Y_Diff;
score_sort(i) = sum(alpha_Y_dot_Diff.*alpha_Y_dot_Diff);
end

[score_sort,idx_sort] = sort(score_sort,'descend');
G = G_possible(idx_sort(1:B),:);
G_possible(idx_sort(1:B),:) = [];
end
