about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/graph/moralize.m
blob: 59beff97728a63ea803d282f32f4d165ee16e5eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
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 = G;
n = length(M);
for i=1:n
  fam = family(G,i);
  M(fam,fam)=1;
end
M = setdiag(M,0);
moral_edges = sparse(triu(max(0,M-G),1));