Skip to content

Chapter 55. Random Walks on Graphs

A random walk on a graph is a process that moves from vertex to vertex by choosing edges at random.

Random walks connect graph theory with probability. They describe diffusion, exploration, sampling, search, ranking, electrical networks, and Markov chains. A graph gives the possible moves. Probability gives the rule for choosing among them.

The basic model is simple. Start at a vertex. At each step, choose one of the current vertex’s neighbors and move there. The sequence of visited vertices is random, but the graph controls which moves are allowed.

55.1 The Simple Random Walk

Let

G=(V,E) G=(V,E)

be a finite undirected graph.

A simple random walk on GG is a sequence of random vertices

X0,X1,X2, X_0,X_1,X_2,\ldots

such that, if the walk is at vertex vv, then the next vertex is chosen uniformly from the neighbors of vv.

Thus, for adjacent vertices uu and vv,

Pr(Xt+1=uXt=v)=1deg(v). \Pr(X_{t+1}=u\mid X_t=v)=\frac{1}{\deg(v)}.

If uu is not adjacent to vv, then

Pr(Xt+1=uXt=v)=0. \Pr(X_{t+1}=u\mid X_t=v)=0.

The next position depends only on the current position. It does not depend on the earlier history of the walk. This is the Markov property. A random walk on a graph is therefore a Markov chain whose state space is the vertex set of the graph.

55.2 Transition Matrix

Let the vertices be

V={v1,v2,,vn}. V=\{v_1,v_2,\ldots,v_n\}.

The transition matrix of the random walk is the n×nn\times n matrix PP defined by

Pij=Pr(Xt+1=vjXt=vi). P_{ij} = \Pr(X_{t+1}=v_j\mid X_t=v_i).

For a simple random walk on an undirected graph,

Pij={1deg(vi),if vivjE,0,otherwise. P_{ij} = \begin{cases} \dfrac{1}{\deg(v_i)}, & \text{if } v_iv_j\in E,\\ 0, & \text{otherwise.} \end{cases}

Each row of PP sums to 11. Such a matrix is called stochastic.

If AA is the adjacency matrix of GG, and DD is the diagonal degree matrix, then

P=D1A. P=D^{-1}A.

This formula assumes there are no isolated vertices. If isolated vertices exist, the random walk rule must be modified, often by adding a self-loop at each isolated vertex.

55.3 Distributions

A probability distribution on VV assigns a nonnegative number to each vertex, with total sum 11.

If the initial distribution is written as a row vector

μ0, \mu_0,

then the distribution after one step is

μ1=μ0P. \mu_1=\mu_0P.

After tt steps,

μt=μ0Pt. \mu_t=\mu_0P^t.

Thus powers of the transition matrix describe the evolution of the walk.

The entry

(Pt)ij (P^t)_{ij}

is the probability that a walk starting at viv_i is at vjv_j after tt steps.

This gives an algebraic way to study random movement on a graph.

55.4 Stationary Distribution

A stationary distribution is a distribution π\pi satisfying

πP=π. \pi P=\pi.

If the walk starts with distribution π\pi, then one step of the walk leaves the distribution unchanged.

For a connected undirected graph, the simple random walk has stationary distribution

π(v)=deg(v)2E. \pi(v)=\frac{\deg(v)}{2|E|}.

This says that the walk spends more time at high-degree vertices. In a dd-regular graph, every vertex has the same degree, so the stationary distribution is uniform.

55.5 Detailed Balance

The stationary distribution above can be checked by detailed balance.

For adjacent vertices uu and vv,

π(u)Puv=deg(u)2E1deg(u)=12E. \pi(u)P_{uv} = \frac{\deg(u)}{2|E|}\cdot\frac{1}{\deg(u)} = \frac{1}{2|E|}.

Similarly,

π(v)Pvu=deg(v)2E1deg(v)=12E. \pi(v)P_{vu} = \frac{\deg(v)}{2|E|}\cdot\frac{1}{\deg(v)} = \frac{1}{2|E|}.

Therefore

π(u)Puv=π(v)Pvu. \pi(u)P_{uv}=\pi(v)P_{vu}.

This condition means that, at stationarity, probability flow from uu to vv equals probability flow from vv to uu.

A Markov chain satisfying detailed balance is called reversible. Random walks on undirected graphs are reversible.

55.6 Regular Graphs

If GG is dd-regular, then

deg(v)=d \deg(v)=d

for every vertex vv.

The stationary distribution becomes

π(v)=dnd=1n. \pi(v)=\frac{d}{nd}=\frac{1}{n}.

Thus the uniform distribution is stationary.

Regular graphs are therefore especially clean for random walks. The walk has no degree bias. In the long run, every vertex has the same probability.

This is one reason regular graphs are common in expander theory.

55.7 Periodicity

A random walk may fail to converge to its stationary distribution because of periodicity.

Consider a bipartite graph with bipartition

V=AB. V=A\cup B.

Every edge goes from AA to BB. Therefore a walk starting in AA is in BB after one step, in AA after two steps, and so on.

The walk alternates sides. It cannot settle smoothly to a fixed limiting distribution at every time.

This is a periodic Markov chain.

A common remedy is the lazy random walk.

55.8 Lazy Random Walks

In a lazy random walk, the walker stays at the current vertex with probability

12, \frac{1}{2},

and moves to a uniformly chosen neighbor with probability

12. \frac{1}{2}.

The transition matrix is

Plazy=12I+12P. P_{\mathrm{lazy}} = \frac{1}{2}I+\frac{1}{2}P.

The self-loop probability removes periodic oscillation.

Lazy random walks are widely used because they preserve the stationary distribution while improving convergence behavior. On connected graphs, laziness makes the chain aperiodic.

55.9 Irreducibility

A random walk is irreducible if every vertex can be reached from every other vertex with positive probability in some number of steps.

For an undirected graph, this is equivalent to the graph being connected.

If GG is disconnected, a walk starting in one component can never reach another component. There is then no single global behavior across the whole graph. Each connected component must be analyzed separately.

Thus connectivity of the graph becomes irreducibility of the Markov chain.

55.10 Mixing

Mixing describes how quickly a random walk approaches its stationary distribution.

A walk mixes rapidly if, after relatively few steps, its distribution is close to π\pi, regardless of the starting vertex.

The mixing time depends strongly on graph structure.

GraphMixing behavior
PathSlow
CycleSlow
Complete graphVery fast
ExpanderFast
Graph with bottleneckSlow

Bottlenecks slow mixing because the walk can remain trapped in one region for a long time.

Expansion speeds mixing because every region has many edges leading outward.

55.11 Random Walks and Expansion

Random walks give a probabilistic view of expansion.

If a set SS has a small boundary, then a walk inside SS has few chances to leave. The set acts as a trap.

If every set has a large boundary, then the walk escapes local regions quickly. The distribution spreads across the graph.

Thus expansion and mixing are closely related.

Expander graphs are important partly because random walks on them mix quickly. They provide sparse graphs that behave, for many purposes, like complete graphs.

55.12 Spectral View

The speed of mixing is controlled by eigenvalues of the transition matrix.

For a connected dd-regular graph,

P=1dA. P=\frac{1}{d}A.

The largest eigenvalue of PP is

1. 1.

The remaining eigenvalues measure how quickly nonuniform components of a distribution decay.

If the second-largest eigenvalue in absolute value is small, then the walk mixes quickly.

The spectral gap is often written as

1λ2, 1-\lambda_2,

where λ2\lambda_2 is the second-largest eigenvalue in an appropriate ordering.

A larger spectral gap means faster convergence.

This is one of the main links between random walks, spectral graph theory, and expansion.

55.13 Hitting Time

The hitting time from uu to vv is the expected number of steps needed for a random walk starting at uu to visit vv for the first time.

It is denoted

H(u,v). H(u,v).

Hitting times need not be symmetric. It may take longer on average to hit vv from uu than to hit uu from vv.

For example, in a graph with one high-degree hub and many leaves, a walk from a leaf reaches the hub in one step. But a walk from the hub may take many tries before reaching a particular leaf.

55.14 Commute Time

The commute time between uu and vv is

C(u,v)=H(u,v)+H(v,u). C(u,v)=H(u,v)+H(v,u).

It is the expected time to go from uu to vv and then return from vv to uu.

Commute time is symmetric.

There is a deep relation between commute times and electrical networks. If each edge is treated as a unit resistor, then commute time is proportional to effective resistance between the two vertices.

This connection is one of the reasons random walks are useful in network analysis.

55.15 Cover Time

The cover time of a graph is the expected time needed for a random walk to visit every vertex.

Cover time measures exploration difficulty.

A complete graph has relatively small cover time because each step can jump to any other vertex.

A path has large cover time because the walk moves locally and often revisits vertices before reaching new ones.

Cover time is important in randomized algorithms, search processes, and network exploration.

55.16 Weighted Graphs

Random walks extend naturally to weighted graphs.

Let each edge uvuv have a positive weight

wuv. w_{uv}.

At vertex uu, the walk chooses neighbor vv with probability proportional to the edge weight:

Puv=wuvxuwux. P_{uv} = \frac{w_{uv}}{\sum_{x\sim u}w_{ux}}.

The weighted degree of uu is

w(u)=xuwux. w(u)=\sum_{x\sim u}w_{ux}.

For an undirected weighted graph, the stationary distribution is

π(u)=w(u)xVw(x). \pi(u)=\frac{w(u)}{\sum_{x\in V}w(x)}.

The unweighted formula is the special case in which every edge has weight 11.

55.17 Directed Graphs

Random walks on directed graphs require more care.

If D=(V,A)D=(V,A) is a directed graph, a walk at vertex uu chooses among outgoing arcs from uu.

If some vertex has out-degree 00, the walk may get stuck unless a special rule is added.

Stationary distributions may fail to exist uniquely unless the directed graph satisfies appropriate strong connectivity and aperiodicity conditions.

Directed random walks are central in ranking algorithms, especially web ranking. PageRank modifies the directed walk by adding teleportation, so the walker sometimes jumps to a random vertex instead of following an outgoing link.

55.18 Absorbing Random Walks

A vertex is absorbing if, once the walk reaches it, the walk stays there forever.

Absorbing walks are useful for modeling processes with terminal states.

Examples include:

SettingAbsorbing state
GameWinning or losing position
Web navigationExit page
Epidemic modelRemoved state
Search processTarget found
Randomized algorithmTermination state

Absorbing Markov chains are studied by separating transient states from absorbing states and computing absorption probabilities and expected absorption times.

55.19 Applications

Random walks on graphs appear in many areas.

AreaUse
Search enginesRanking pages by link structure
SamplingDraw samples from large state spaces
Network analysisMeasure centrality and reachability
Machine learningGraph embeddings and label propagation
Distributed systemsGossip and load balancing
AlgorithmsRandomized exploration
PhysicsDiffusion on networks
BiologyMovement through interaction networks

The common pattern is movement through a structured set of possible states.

55.20 Common Mistakes

A common mistake is to assume that the stationary distribution is always uniform. It is uniform for regular undirected graphs, but in general it is proportional to degree.

Another mistake is to confuse existence of a stationary distribution with convergence to it. A bipartite connected graph has a stationary distribution, but the ordinary walk is periodic.

A third mistake is to ignore disconnected components. A walk cannot move between components.

A fourth mistake is to assume that edge-disjoint paths alone guarantee fast mixing. Bottlenecks and expansion control mixing more directly.

55.21 Summary

A random walk is a probabilistic process that moves through a graph by following edges.

ConceptMeaning
Simple random walkMove uniformly to a neighbor
Transition matrixMatrix of one-step probabilities
Stationary distributionDistribution unchanged by the walk
Lazy walkWalk that may stay in place
Mixing timeTime to approach stationarity
Hitting timeExpected time to reach a vertex
Cover timeExpected time to visit all vertices
Spectral gapEigenvalue measure controlling convergence

Random walks provide a probabilistic language for graph structure. They connect connectivity, expansion, spectra, algorithms, sampling, ranking, and network dynamics.