Skip to contents

Convert a DAG object from other libraries to an adjacency matrix.

Usage

toMatrix(network)

Arguments

network

A bnlearn or igraph object.

Value

An adjacency matrix representation of network.

Examples

toMatrix(bnlearn::empty.graph(LETTERS[1:6]))
#>   A B C D E F
#> A 0 0 0 0 0 0
#> B 0 0 0 0 0 0
#> C 0 0 0 0 0 0
#> D 0 0 0 0 0 0
#> E 0 0 0 0 0 0
#> F 0 0 0 0 0 0
toMatrix(igraph::sample_k_regular(10, 2))
#>       [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
#>  [1,]    0    0    1    0    0    0    0    1    0     0
#>  [2,]    0    0    0    0    0    1    0    0    0     1
#>  [3,]    1    0    0    0    0    0    0    0    1     0
#>  [4,]    0    0    0    0    1    1    0    0    0     0
#>  [5,]    0    0    0    1    0    0    1    0    0     0
#>  [6,]    0    1    0    1    0    0    0    0    0     0
#>  [7,]    0    0    0    0    1    0    0    0    1     0
#>  [8,]    1    0    0    0    0    0    0    0    0     1
#>  [9,]    0    0    1    0    0    0    1    0    0     0
#> [10,]    0    1    0    0    0    0    0    1    0     0