PageRank algorithm implementation:
\[PR(A) = (1 - \alpha) + \alpha (\frac{PR(B)}{Out(B)}+\frac{PR(C)}{Out(C)}+\frac{PR(D)}{Out(D)}+...)\]
\(A, B, C ,D...\) are different vertex. \(PR\) is the pagerank value of vertex, \(Out\) represents the out degree of vertex and \(\alpha\) is the damping factor, normally equals to 0.85
The algorithm’s pseudocode is as follows
for each edge (u, v) in graph // calculate du degree
degree(v) += 1
for each node u in graph // initiate DDR
const(u) := alpha / degree(u)
PR_old(u) := 1 / total vertex number
while norm(PR_old - PR_new) > tolerance // iterative add
for each vertex u in graph
PR_new(u) := 1 - alpha
for each vertex v point to u
PR_new(u) += const(v)*PR_old(v)
return PR_new