o of the pagerank algorithm, based on code by Cleve Moler
% See also pagerankDemoMoler, pagerankDemoGui, surfer, pagerankpow
%%
%% 6 node web example

% This file is from pmtk3.googlecode.com

i = [ 2 6 3 4 4 5 6 1 1];
j = [ 1 1 2 2 3 3 3 4 6];
n = 6;
G  = sparse(i,j,1,n,n); % sparse n x n matrix with 1's in specified positions

c = sum(G,1);
k = find(c~=0); % non zero outdegree
D = sparse(k,k,1./c(k),n,n);
e = ones(n,1);
I = speye(n,n);
p = 0.85;

%% Find the stationary distribution
pi = normalize((I - p*G