# random_walk

From igraph v1.2.2
by Gabor Csardi

##### Random walk on a graph

Do a random walk. From the given start vertex, take the given number of
steps, choosing an edge from the actual vertex uniformly randomly. Edge
directions are observed in directed graphs (see the `mode`

argument
as well). Multiple and loop edges are also observed.

##### Usage

```
random_walk(graph, start, steps, mode = c("out", "in", "all"),
stuck = c("return", "error"))
```

##### Arguments

- graph
The input graph, might be undirected or directed.

- start
The start vertex.

- steps
The number of steps to make.

- mode
How to follow directed edges.

`"out"`

steps along the edge direction,`"in"`

is opposite to that.`"all"`

ignores edge directions. This argument is ignored for undirected graphs.- stuck
What to do if the random walk gets stuck.

`"return"`

returns the partial walk,`"error"`

raises an error.

##### Value

A vertex sequence containing the vertices along the walk.

##### Examples

```
# NOT RUN {
## Stationary distribution of a Markov chain
g <- make_ring(10, directed = TRUE) %u%
make_star(11, center = 11) + edge(11, 1)
ec <- eigen_centrality(g, directed = TRUE)$vector
pg <- page_rank(g, damping = 0.999)$vector
w <- random_walk(g, start = 1, steps = 10000)
## These are similar, but not exactly the same
cor(table(w), ec)
## But these are (almost) the same
cor(table(w), pg)
# }
```

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

### Community examples

Looks like there are no examples yet.