Try the following code:
A = {[1,2,3,4], [1,2,3,6], [1,2,3,8], [1,2,6,7,8], [1,6,8], [2,3,4,7], [3,4,6], [3,4,6,7], [3,4,6,7,8], [3,6,8], [6,7,8], [1,5]};
B =[1 2; 1 4; 1 8; 1 5; 1 6; 2 7; 2 3; 3 6; 3 8; 3 4; 4 7; 4 6; 7 6; 7 8; 6 8];
B_bk = B;
A_new = cell([],1);
length_B = cell([],1);
%% sort A
[~,I] = sort(cellfun(@length,A));
A = A(I);
C = [];
for i=1:length(A)
temp = [A{i} A{i}(1)];
C = [C;[temp(1:end-1)' temp(2:end)']];
[~,X] = setdiff(sort(B_bk,2),sort(C,2),'rows','stable');
B = B_bk(X,:);
length_B{i} = length(B);
if i==1
A_new{i} = A{i};
end
%% problem to write condition
if i>1
if length_B{i-1}- length_B{i}>0 %%???
A_new{i} = A{i};
end
end
end
A_new=A_new(~cellfun(@isempty,A_new))