检索类igraph
的图的随机矩阵。
用法
stochastic_matrix(
graph,
column.wise = FALSE,
sparse = igraph_opt("sparsematrices")
)
详细信息
设 \(M\) 是一个具有实数非负条目的 \(n \times n\) 邻接矩阵。 让我们定义 \(D = \textrm{diag}(\sum_{i}M_{1i}, \dots, \sum_{i}M_{ni})\)
(行)随机矩阵定义为 $$W = D^{-1}M,$$,假设 \(D\) 是非奇异的。 列随机矩阵以对称方式定义。
作者
Gabor Csardi csardi.gabor@gmail.com
示例
library(Matrix)
## g is a large sparse graph
g <- sample_pa(n = 10^5, power = 2, directed = FALSE)
W <- stochastic_matrix(g, sparse = TRUE)
## a dense matrix here would probably not fit in the memory
class(W)
#> [1] "dgCMatrix"
#> attr(,"package")
#> [1] "Matrix"
## may not be exactly 1, due to numerical errors
max(abs(rowSums(W)) - 1)
#> [1] 0