| get.stochastic {igraph} | R Documentation |
Retrieves the stochastic matrix of a graph of class
igraph.
get.stochastic(graph, column.wise = FALSE, sparse =
getIgraphOpt("sparsematrices"))
graph |
The input graph. Must be of class |
column.wise |
If |
sparse |
Logical scalar, whether to return a sparse matrix. The
|
Let M be an n x n adjacency matrix with real non-negative entries. Let us define D=diag( sum(M[1,i], i), ..., sum(M[n,i], i) )
The (row) stochastic matrix is defined as
W = inv(D) M,
where it is assumed that D is non-singular. Column stochastic matrices are defined in a symmetric way.
A regular R matrix or a matrix of class Matrix if a
sparse argument was TRUE.
Gabor Csardi csardi.gabor@gmail.com
library(Matrix) ## g is a large sparse graph g <- barabasi.game(n = 10^5, power = 2, directed = FALSE) W <- get.stochastic(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)