如何用iGraph和RStudio在R中使用“get.邻接()”来保存邻接矩阵?

时间:2021-06-25 16:20:12

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

是否可以在“get.邻接()”作为R中的邻接矩阵来保存邻接矩阵?我试着

test <- get.adjacency(network)

but I´m getting the error

但我´错误

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

I´m using RStudio and the package iGraph.

我´iGraph使用RStudio和包。

1 个解决方案

#1


5  

Try using sparse=FALSE in the call to get.adjacency(...)

在调用get.邻接(…)时使用稀疏=FALSE。

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"

#1


5  

Try using sparse=FALSE in the call to get.adjacency(...)

在调用get.邻接(…)时使用稀疏=FALSE。

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"