INAIO Guide Stage 1 12Graph Theory and Algorithms
12.6 Random walks and PageRank
Find the probability of reaching each node in a random walk, then apply the idea to PageRank.
Suppose an object moves around a graph, choosing its next edge at random according to a rule at its current node. We may not know where it will be after one or two moves, but we can ask a precise question: what is the probability that it is at a particular node? A random walk is this repeated random movement. The next-step chances depend on the current node, so instead of predicting one path, we track a probability for every possible current node and update those probabilities after each move. This can model movement between locations, changes between states, or visits through a network.
This is intermediate to advanced Stage 1 material. Review conditional probability and sink components first. Transition matrices explain the compact update below, but you can follow the two-node example without them. MIT OpenCourseWare's Centrality and Web Search lecture develops this interpretation further.
A basic idea: add the chances of arriving at a node
Take two nodes, and . From , the walker must move to . From , it moves to with probability or stays at with probability . Suppose it starts equally likely at either node: . This pair of starting probabilities is a distribution; its entries add to .
After one move, the walker can reach only by starting at and choosing . Multiply the chances: . It can reach in two different ways: start at and move there, or start at and stay. Add those separate chances: . The new distribution is , still totalling .
For the second move, repeat from the new distribution: and . We have found the probability of being at either node after two steps without having to guess which single path the walker took. For example, the chance of ending at also comes from adding the two possible two-step paths to : and .
A quick tour of random walks
For every possible move from node to node , let be its probability. A move that is not allowed has probability ; the probabilities of all moves leaving one node add to . If a node has no outgoing edge, the model must supply a rule, such as staying there with probability . Let be the probability that the walker is at node after moves. To find the probability at a particular node after one more move, add the probability arriving from every possible previous node:
Each term multiplies the chance of being at by the chance of moving from to . Adding the terms combines alternative routes to . A single walker takes one route; describes our uncertainty over all routes it could have taken.
For a compact calculation, use a row-vector convention: and . Each row of the transition matrix lists the outgoing probabilities from one node and must sum to . For our two-node walk,
When repeated updates settle, a stationary distribution satisfies : one more move does not change the probabilities. In this walk, receives half of 's probability, so a stable pair must satisfy and . Solving gives . Not every graph's walk settles from every start. A closed group can trap a walker, and a strict back-and-forth cycle can make probabilities alternate.
PageRank: a use of the random walk
Now make the nodes web pages and the directed edges links. A visitor following a random outgoing link performs a random walk; a page visited more often in the long run gets a larger walk-based score. An ordinary link walk has problems: a page with no outgoing link has nowhere to send its probability, and a sink group can trap the visitor. PageRank keeps the walk but sometimes makes a random jump, called teleportation.
First give each page with no outgoing links a fallback outgoing distribution, often the same distribution used for jumps, so every row of still sums to . Let be the chance of following a link and the jump distribution. One PageRank update is
The first part follows links; the second part redistributes a small amount of probability through jumps. The entries remain nonnegative and add to . If gives every page a positive chance, a visitor can eventually get out of any sink and reach any page. Repeating the update approaches a stable PageRank distribution in this finite model.
For the two-node example, let and . The link-only move from gives ; adding jumps gives . Another update gives . The stable PageRank score solves and is , approximately . It describes this chosen link-and-jump model, not an intrinsic quality of a page.
The animation separates following a link from adding teleportation. Use Next to see the probability move and the total remain .
Application 1: a non-web random walk
A two-state model says a dry day is followed by a dry day with chance , and a wet day is followed by a dry day with chance . Starting from a certainly dry day, what is the distribution after two steps?
- Write the rows in dry, wet order. ; each row sums to .
- Take one step. gives .
- Take another. .
This is an ordinary random walk with no teleportation. It uses the same multiply-and-add rule as the two-node example.
Application 2: rank two pages
Use the two-page graph above with , uniform jumps, and . What is the distribution after two PageRank updates?
- Follow links from the start. .
- Mix in jumps. .
- Repeat. , so .
Page has the larger score after two rounds; both entries still add to .
Resources
| Source | Title | Why read it |
|---|---|---|
| MIT OpenCourseWare | Centrality and Web Search | Connect random walks, stationary probabilities, and PageRank. |
Finished this module? Mark it done.
Comments
Stuck on something, spotted a mistake, or found a resource that helped you? Tell us below.
Loading comments