# get.stochastic

From igraph v0.6.5-2
by Gabor Csardi

##### Stochastic matrix of a graph

Retrieves the stochastic matrix of a graph of class
`igraph`

.

- Keywords
- graphs

##### Usage

```
get.stochastic(graph, column.wise = FALSE, sparse =
getIgraphOpt("sparsematrices"))
```

##### Arguments

- graph
- The input graph. Must be of class
`igraph`

. - column.wise
- If
`FALSE`

, then the rows of the stochastic matrix sum up to one; otherwise it is the columns. - sparse
- Logical scalar, whether to return a sparse matrix. The
`Matrix`

package is needed for sparse matrices.

##### Details

Let $M$ be an $n \times n$ adjacency matrix with real non-negative entries. Let us define $D = \textrm{diag}(\sum_{i}M_{1i}, \dots, \sum_{i}M_{ni})$ The (row) stochastic matrix is defined as $$W = D^{-1}M,$$ where it is assumed that $D$ is non-singular. Column stochastic matrices are defined in a symmetric way.

##### Value

- A regular Rmatrix or a matrix of class
`Matrix`

if a`sparse`

argument was`TRUE`

.

##### See Also

##### Examples

```
## 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)
```

*Documentation reproduced from package igraph, version 0.6.5-2, License: GPL (>= 2)*

### Community examples

Looks like there are no examples yet.