Transform an edgelist to a matrix
Examples
A <- matrix(c(
0, 1, 1, 0, 0, 0, 0, 1, 0,
1, 0, 1, 0, 0, 0, 0, 0, 0,
1, 1, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 1, 1, 0, 0, 0,
0, 0, 0, 1, 0, 0, 0, 0, 0,
0, 0, 0, 1, 0, 0, 1, 1, 0,
0, 0, 0, 0, 0, 1, 0, 1, 0,
1, 0, 0, 0, 0, 1, 1, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0
), byrow = TRUE, ncol = 9)
rownames(A) <- letters[1:nrow(A)]
colnames(A) <- rownames(A)
E <- matrix_to_edgelist(A)
edgelist_to_matrix(E, label = c("i"), digraph = FALSE)
#> a b c d e f g h i
#> a 0 1 1 0 0 0 0 1 0
#> b 1 0 1 0 0 0 0 0 0
#> c 1 1 0 0 0 0 0 0 0
#> d 0 0 0 0 1 1 0 0 0
#> e 0 0 0 1 0 0 0 0 0
#> f 0 0 0 1 0 0 1 1 0
#> g 0 0 0 0 0 1 0 1 0
#> h 1 0 0 0 0 1 1 0 0
#> i 0 0 0 0 0 0 0 0 0