K.S.
2022-05-11
First, let us discuss the variables needed for this algorithm.
Second, the steps for calculating PageRank of a given page \( A \):
\[ \begin{align} (1 - d) \end{align} \]
\[ \begin{align} d*\sum_{k=1}^n\left(\frac{PR(T_1)}{C(T_1)} + \cdots + \frac{PR(T_n)}{C(T_n)}\right) \end{align} \]
\[ \begin{align} PR(A) = (1-d) + d*\sum_{k=1}^n\left(\frac{PR(T_1)}{C(T_1)} + \cdots + \frac{PR(T_n)}{C(T_n)}\right) \end{align} \]
Let's put them to use in a short example:
d = 0.85; # The dampening variable
a = 0;
b = 0;
i = 45; # Our guess for some repetition
while (i != 0)
a = (1 - d) + d*b;
b = (1 - d) + d*a;
printf("a = %8d \t b = %8d\n", [a, b])
i -= 1;
endwhile
a = 0.556295 b = 0.62285
a = 0.832657 b = 0.857758
a = 0.936887 b = 0.946354
a = 0.976197 b = 0.979767
a = 0.991023 b = 0.992369
a = 0.996614 b = 0.997122
a = 0.998723 b = 0.998915
a = 0.999518 b = 0.999591
a = 0.999818 b = 0.999846
a = 0.999931 b = 0.999942
a = 0.999974 b = 0.999978
a = 0.99999 b = 0.999992
a = 0.999996 b = 0.999997
a = 0.999999 b = 0.999999
a = 0.999999 b = 1
a = 1 b = 1
Octave code slides, we see that our guess caused the average between pages \( A \) and \( B \) to approach and eventually make it to an average page rank of 1. function [v] = rank2(M, d, v_quadratic_error)
N = size(M, 2)
v = rand(N, 1);
v = v ./ norm(v, 1);
last_v = ones(N, 1) * inf;
M_hat = (d.*M) + (((1-d)/N).*ones(N,N));
while (norm(v-last_v,2)>v_quadratic_error)
last_v = v;
v = M_hat * v;
endwhile
endfunction
M = [ 0 0 0 0 1;
0.5 0 0 0 0;
0.5 0 0 0 0;
0 1 0.5 0 0;
0 0 0.5 1 0];
rank2(M, 0.85, 0.001)
ranks =
0.2545
0.1382
0.1382
0.2057
0.2635