算法原理不在赘述,请参考:
http://blog.csdn.net/androidlushangderen/article/details/43311943
将代码保存为.py格式,默认使用的数据是代码文件所在目录下data目录下的 pgr_data.txt 文件分别作为源数据输入。以上参数可以在源代码中修改,也可以使用命令行参数传入,参考以下启动方式:
python pagerank.py pgr_data.txt命令中后参数为输入数据的途径。
代码中设立了四个参数,分别为
附上测试数据分别为PageRank算法的阻尼系数,网络的最大节点数,迭代最大次数,最大误差允许。q=0.8 ### size = 100 ### the size of the networks times = 200 ### the maxmim times for iterations error = 0.0001 ### the error used for stoping the iterations
第一个参数直接决定了迭代的次数和最终结果的性能,最后两个参数用来限制迭代次数