graph-coerce.Rd
Methods for changing graph representations
coerceGraph(object, class)
graph_as(object, outtype, intype = NULL)
coerceGraph is used in the book "Graphical models with R". A more generic approach is as().
g1 <- ug(~a:b+b:c)
as(g1, "igraph")
#> IGRAPH cb802aa UN-- 3 2 --
#> + attr: name (v/c)
#> + edges from cb802aa (vertex names):
#> [1] a--b b--c
as(g1, "matrix")
#> a b c
#> a 0 1 0
#> b 1 0 1
#> c 0 1 0
as(g1, "Matrix")
#> 3 x 3 sparse Matrix of class "dsCMatrix"
#> a b c
#> a . 1 .
#> b 1 . 1
#> c . 1 .
as(g1, "dgCMatrix")
#> 3 x 3 sparse Matrix of class "dgCMatrix"
#> a b c
#> a . 1 .
#> b 1 . 1
#> c . 1 .
## graph_as(g1, "ugList") ## Fails
## getCliques(g1) ## Works
l1 <- list(c("a" ,"b"), c("b", "c"))
graph_as(l1, "graphNEL", "ugList")