Weighted PageRank Algorithm
Prerequisite: PageRank Algorithm
The more popular a webpage is, the more are the linkages that other webpages tend to have to them. Weighted PageRank algorithm is an extension of the conventional PageRank algorithm based on the same concept.
Weighted PageRank algorithm assigns higher rank values to more popular (important) pages instead of dividing the rank value of a page evenly among its outlink pages. Each outlink page gets a value proportional to its popularity, i.e. its number of inlinks and outlinks.
To a webpage ‘u’, an inlink is a URL of another webpage which contains a link pointing to ‘u’. Similarly to webpage ‘u’, an outlink is a link appearing in ‘u’ which points to another webpage. The number of inlinks is represented by Win(v,u) and the number of outlinks is represented as Wout(v,u).
Win(v,u) is the weight of link (v, u) calculated based on the number of inlinks of page u and the number of inlinks of all reference pages of page v.
Here, Ip and Iu represent the number of inlinks of page ‘p’ and ‘u’ respectively. R(v) represents the list of all reference pages of page ‘v’.
Wout(v,u) is the weight of link (v, u) calculated based on the number of outlinks of page u and the number of outlinks of all reference pages of page v.
Here, Op and Ou represent the number of outlinks of page ‘p’ and ‘u’ respectively. R(v) represents the list of all reference pages of page ‘v’.
Based on the importance of all pages as describes by their number of inlinks and outlinks, the Weighted PageRank formula is given as:
Here, PR(x) refers to the Weighted PageRank of page x.
d refers to the damping factor. The PageRank theory holds that an imaginary surfer who is randomly clicking on links will eventually stop clicking. The probability, at any step, that the person will continue is the damping factor.
Imagine a scenario where there are 5 webpages A, B, C, D and E.
- Site A (outlinks to B, C, D)
- Site B (outlinks to A, C, D)
- Site C (outlinks to D)
- Site D (outlinks to C, E)
- Site E (outlinks to B, C, D)
The below code demonstrates how the Weighted PageRank for each webpage in the above scenario can be calculated. The input is taken in the form of an outlink matrix and is run for a total of 5 iterations.
Number of iterations is: 5 Page rank of node 1 is : 0.7563090216610497 Page rank of node 2 is : 0.7570825988098917 Page rank of node 3 is : 1.021617613959075 Page rank of node 4 is : 0.9412927238508162 Page rank of node 5 is : 0.7735323180962704 Sum of all page ranks: 4.249834276377103
Attention reader! Don’t stop learning now. Get hold of all the important Machine Learning Concepts with the Machine Learning Foundation Course at a student-friendly price and become industry ready.