
%% Setup simple graph
A = sparse(6,6);
A(1,1) = 1;
A(2,[1,3]) = 1;
A(3,5) = 1;
A(4,[2,3,5]) = 1;
A(5,6) = 1; A(6,5) = 1;
n = 6;
full(A)
%% Compute the row-stochastic version
d = sum(A,2);
P = diag(1./d)*A;
P

%% Compute PageRank using our richardson method

[x,reshist]= pr_rich(P,0.85,ones(n,1)./n,1e-8);
semilogy(reshist);

%% Now try with a HUGE graph
addpath('~/dev/libbvg/matlab/');
G = bvgraph('/Users/dgleich/data/webgraphs/itgraphs/webbase-2001');
size(G,1)
nnz(G)
whos
P = ssbvgraph(G);
n = size(P,1);
[x,reshist]= pr_rich(P,0.85,ones(n,1)./n,1e-3);
semilogy(reshist);
close all;
semilogy(reshist);
