PAGERANKDEMO draws the 6-node "tiny web" in Section 2.11 of "Numerical Computing with MATLAB", by Cleve Moler, SIAM, 2004. It then simulates the computation of Google's PageRank algorithm, by randomly selecting links to traverse. If a link is traversed, the edge and the target node are displayed in red. If the "random surfer" jumps to an arbitrary page, the target node is displayed in blue.
The number of hits at each node, and the page rank (in %) are displayed % on each node. Note that after a large number of steps, the PageRanks (in percentages) converge to the values given in Section 2.11 of Moler (alpha: .321, sigma: .2007, beta: .1705, delta: .1368, gamma: .1066, rho: .0643). See also David Gleich's pagerank in the File Exchange, file id 11613, for computing pageranks of really large graphs.
Note that this method is NOT how the PageRank is actually computed. Instead the eigenvalue problem A*x=x is solved for x, where A is the Markov transition matrix, A = p*G*D e*z', where G is the binary matrix used here. The method here is a simplistic random-hopping demonstration of the Markov process, to motivate the A*x=x formulation of the problem. In this example, A does control how the transitions are made, but the matrix A is not formed explicitly.
This demo only operates on a single graph. It is meant as a simple demo only, suitable for in-class use. To compute the PageRanks for an arbitrary graph, use pagerank.m from Moler's book, or the power method (repeat x=A*x, until convergence, where A is the Markov transition matrix of the web).