最近、PageRankを計算するPHPソースコードを公開している人がいたので、Rubyで書き直してみました。 PHPからRubyへは移植というよりほとんど写経のような感じでそのままポーティングできます。 pagerank.rb #!/usr/bin/ruby # original PHP source http://phpir.com/pagerank-in-php def calculatePageRank(linkGraph, dampingFactor = 0.15) pageRank = Hash.new tempRank = Hash.new nodeCount = linkGraph.length linkGraph.each {|node, outbound| pageRank[node] = 1/nodeCount tempRank[node] = 0 } change =
![Rubyでもっとも重要なライブラリは何か?PageRankで計算してみた - aike’s blog](https://cdn-ak-scissors.b.st-hatena.com/image/square/7915984369e4de15aab5538f2d010cfd09ef5f0a/height=288;version=1;width=512/https%3A%2F%2Fcdn-ak.f.st-hatena.com%2Fimages%2Ffotolife%2Fa%2Faike%2F20091223%2F20091223164342.jpg)