Daniel@0: function [M, moral_edges] = moralize(G) Daniel@0: % MORALIZE Ensure that for every child, all its parents are married, and drop directionality of edges. Daniel@0: % [M, moral_edges] = moralize(G) Daniel@0: Daniel@0: M = G; Daniel@0: n = length(M); Daniel@0: for i=1:n Daniel@0: fam = family(G,i); Daniel@0: M(fam,fam)=1; Daniel@0: end Daniel@0: M = setdiag(M,0); Daniel@0: moral_edges = sparse(triu(max(0,M-G),1));