function u = inverse_relation(v, n)
%
% u = inverse_relation(v, n)
% u(j) = the i's s.t. j \member v(i), 1<=j<=n, 1<=i<=|v|
% u and v are 1D cell arrays.
% Example: v = { [2,3], [3,4] }, u = { [], [1], [1,2], [2] }

m = length(v);
R = zeros(m, n);
for i=1:m
  for j=1:length(v{i})
    R(i,v{i}) = 1;
  end
end
u = cell(1,n);
for j=1:n
  col = R(:,j);
  u{j} = find(col==1)';
end


