graph-moralize.Rd
Moralize a directed acyclic graph which means marrying parents and dropping directions.
moralize(object, ...)
# Default S3 method
moralize(object, result = NULL, ...)
A moralized graph represented either as a graphNEL
, a
dense matrix
or a sparse dgCMatrix
.
The workhorse is the moralizeMAT
function.
mcs
, junction_tree
, rip
,
ug
, dag
daG <- dag(~me+ve,~me+al,~ve+al,~al+an,~al+st,~an+st)
moralize(daG)
#> IGRAPH 51bfdae UN-- 12 0 --
#> + attr: name (v/c), label (v/c)
#> + edges from 51bfdae (vertex names):
daG <- dag(~me+ve,~me+al,~ve+al,~al+an,~al+st,~an+st, result="matrix")
moralizeMAT(daG)
#> me ve al an st
#> me 0 0 0 0 0
#> ve 0 0 0 0 0
#> al 0 0 0 0 0
#> an 0 0 0 0 0
#> st 0 0 0 0 0
if (require(igraph)){
M <- matrix(c(1,2,3,3), nrow=2)
G <- graph.edgelist(M)
G
V(G)$name
moralize(G)
}
#> Loading required package: igraph
#>
#> Attaching package: ‘igraph’
#> The following objects are masked from ‘package:gRbase’:
#>
#> edges, is_dag, topo_sort
#> The following objects are masked from ‘package:stats’:
#>
#> decompose, spectrum
#> The following object is masked from ‘package:base’:
#>
#> union
#> Warning: `graph.edgelist()` was deprecated in igraph 2.0.0.
#> ℹ Please use `graph_from_edgelist()` instead.
#> IGRAPH ff1512d UN-- 3 3 --
#> + attr: name (v/c), label (v/c)
#> + edges from ff1512d (vertex names):
#> [1] 1--2 1--3 2--3