diff options
Diffstat (limited to 'sourcecodes/bnt-master/graph/moralize.m')
| -rw-r--r-- | sourcecodes/bnt-master/graph/moralize.m | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sourcecodes/bnt-master/graph/moralize.m b/sourcecodes/bnt-master/graph/moralize.m new file mode 100644 index 00000000..59beff97 --- /dev/null +++ b/sourcecodes/bnt-master/graph/moralize.m @@ -0,0 +1,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)); |
