谷歌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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值