谷歌pagerank算法 python实现

Google’s PAGERANK uses the hyperlink structure of the Web to view in-links into a page as a recommendation of that page from the author of the in-linking page and In-links. Hence,Good pages will have in-links from good pages;and conversely, good pages will have out-links to good pages. And in-links from good pages should carry more weight than in-links from marginal pages.

Google PAGERANK have following characters:

1. Pages vote for the importance of other pages by linking to them. 

The more in-links a page has, the more important it is! 

2. One person, one vote. 

If a page has more than one out-link, it must split its vote! 

3. A link to page k from an important page should boost page k’s importance score more than a link from an unimportant page. 

It matters who your friends and supporters are! 

Consider the web surfer can choose to stay put or jump to any other node with equal probability, We should modify adjacency matrix with equation r=(aB+(1-a)E)r=Gr,where a=0.85 and E=e*eT/m. 

Experimental procedures

Step 1: find the first 500 web pages from http://www.jnu.edu.cn via the above crawler, store them with a array web Link[ ];

 

Step 2: traverse web Link[ ] to computing the 500 web Pages’ connectivity, store    them with a 500*500 2-dimension array aMatrix[ ][ ], which is adjacency    matrix;

 

Step 3: recording and weighting the “votes”: for every page, use (aB+(1-a)E) to change aMartix[ ][ ] to gMatrix[ ][ ], where B=aMatrix,E=e*eT/m and a=0.85; 

 

Step 4: give a initial x[ ], use Power Iteration to compute dominant eigenvector of gMatrix[ ][ ], compute for 5000 times, and finally x[ ] is dominant eigenvector of gMatrix[ ]; 

 

Step 5: sort V_dic[ ] and list the top 20 web pages. 

Result analysis

 

Adjacency matrix for the starting page http://www.jnu.edu.cn

Top 20 pages that have the most weight

VIExperimental summary

This experiment did take me plenty of energy. At the beginning, I have to write a spider program to spider 500 websites using breadth first search starting out with the index page of Guangzhou Jinan University. Then, I use Python instead of Matlab because of the convenience of it, which can be reflect in the method dealing with network. In a word, this experiment benefits me quite a lot.

Code:  https://github.com/jsphLim/PageRank

plot the matrix

谷歌pagerank算法 python实现_第1张图片

你可能感兴趣的:(高级算法,云计算与大数据)