How to save adjacency matrix with "get.adjacency ()" in R, with iGraph and RStudio?

Is it possible to save the adjacency matrix after "get.adjacency ()" as an adjacency matrix in R? I tried

test <- get.adjacency(network)

but i get an error

Error in View : cannot coerce class "structure("dgCMatrix", package = "Matrix")" to a data.frame. 

I am using RStudio and the iGraph package.

+4
source share
1 answer

Try using sparse=FALSEin a callget.adjacency(...)

g <- graph.full(5)
test <- get.adjacency(g)
class(test)
# [1] "dgCMatrix"
# attr(,"package")
# [1] "Matrix"

test <- get.adjacency(g,sparse=FALSE)
class(test)
# [1] "matrix"
+5
source

Source: https://habr.com/ru/post/1547323/


All Articles