function [M, moral_edges] = moralize(G)
% MORALIZE Ensure that for every child, all its parents are married, and drop directionality of edges.
% [M, moral_edges] = moralize(G)

%M = triu(G,1) + triu(G,1)'; % add links in both directions
M = G;
n = length(M);
for i=1:n
  ps = parents(G,i);
  if length(ps) > 1
    M(ps,ps) = 1;
  end
end
%M = setdiag(M,0);
moral_edges = sparse(triu(max(0,M-G),1));
