R igraph 手册页

如果您从 R 中使用 igraph,请使用此选项

stochastic_matrix {igraph}R 文档

图的随机矩阵

描述

检索类 igraph 的图的随机矩阵。

用法

stochastic_matrix(
  graph,
  column.wise = FALSE,
  sparse = igraph_opt("sparsematrices")
)

参数

输入图。必须是 igraph 类。

column.wise

如果 FALSE,则随机矩阵的行之和为 1;否则为列之和。

sparse

逻辑标量,是否返回稀疏矩阵。稀疏矩阵需要 Matrix 包。

详细信息

M 是一个具有实非负条目的 n \times n 邻接矩阵。让我们定义 D = \textrm{diag}(\sum_{i}M_{1i}, \dots, \sum_{i}M_{ni})

(行)随机矩阵定义为

W = D^{-1}M,

其中假定 D 是非奇异的。列随机矩阵以对称方式定义。

如果 sparse 参数为 TRUE,则为常规矩阵或 Matrix 类的矩阵。

作者

Gabor Csardi csardi.gabor@gmail.com

参见

as_adj

示例


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)

## may not be exactly 1, due to numerical errors
max(abs(rowSums(W))-1)


[包 igraph 版本 1.3.5 索引]