Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
A Ruby PageRank like implementation.
Tree: 3cf28d6341

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
ext
spec
.document
.gitignore
LICENSE
README.rdoc
Rakefile
VERSION
benchmark.rb
rankable_graph.gemspec

README.rdoc

rankable_graph

A Ruby PageRank like implementation.

Description

This gem is mostly writen in C with a pretty Ruby wrapper. It's intended to be used for big but not huge graphs, as those are better processed with a map-reduce distributed solution.

Usage

rankable_graph = RankableGraph.new

#First we draw our directed graph using the link method which receives as parameters two identifiers.
#The only restriction for the identifiers is that they should be integers.
rankable_graph.link(1234, 4312)
rankable_graph.link(9876, 4312)
rankable_graph.link(4312, 9876)
rankable_graph.link(8888, 4312)

probability_of_following_a_link = 0.85 # The bigger the number, less probability we have to teleport to some random link
tolerance = 0.0001 # the smaller the number, the more exact the result will be but more CPU cycles will be needed

rankable_graph.rank(probability_of_following_a_link, tolerance) do |identifier, rank|
  puts "Node #{identifier} rank is #{rank}"
end

Which outputs

Node 1234 rank is 0.0375000014901161
Node 4312 rank is 0.479941636323929
Node 9876 rank is 0.445058345794678
Node 8888 rank is 0.0375000014901161

This ranks represent the probabilities that a certain node will be visited. For more examples please refer to the tests.

Requirements

  • Ruby 1.9

  • glib2 >= 2.22.2

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright

Copyright © 2009 Cubox. See LICENSE for details.

Something went wrong with that request. Please try again.