pagerank python实现

时间:2012-09-14 14:51:12

标签: python numpy pagerank

我想将PageRank MATLAB/Octave implementation转换为python,但是当涉及到:

a=array([[inf]])  
last_v = dot(ones(N,1),a)

TypeError

Traceback (most recent call last):
File "/home/googcheng/page_rank.py", line 18, in <module>
pagerank(0,0)
File "/home/googcheng/page_rank.py", line 14, in pagerank
last_v = dot(ones(N,1),a)
File "/usr/lib/python2.7/dist-packages/numpy/core/numeric.py", line 1819, in ones
a = empty(shape, dtype, order)
TypeError: data type not understood

一些代码https://gist.github.com/3722398

1 个答案:

答案 0 :(得分:1)

ones的第一个参数,即形状,应该是一个元组。将ones(N,1)更改为ones((N,1))