Permalink
Browse files

Update README

  • Loading branch information...
1 parent 540002b commit 166c10aafafbf5973a68541509918299670a20f4 @dcadenas dcadenas committed Mar 28, 2012
Showing with 65 additions and 43 deletions.
  1. +65 −43 README.rdoc
View
@@ -1,79 +1,100 @@
-{<img src="https://secure.travis-ci.org/cubox/rankable_graph.png" />}[http://travis-ci.org/cubox/rankable_graph]
-= rankable_graph
+[![](https://secure.travis-ci.org/cubox/rankable_graph.png)](http://travis-ci.org/cubox/rankable_graph)
+rankable_graph
+==============
-A Ruby {PageRank}[http://en.wikipedia.org/wiki/PageRank] like implementation.
+A Ruby [PageRank](http://en.wikipedia.org/wiki/PageRank) like implementation.
-{<img src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/PageRanks-Example.svg/596px-PageRanks-Example.svg.png" />}[http://en.wikipedia.org/wiki/PageRank]
+[![](http://upload.wikimedia.org/wikipedia/commons/thumb/f/fb/PageRanks-Example.svg/596px-PageRanks-Example.svg.png)](http://en.wikipedia.org/wiki/PageRank)
-== Description
+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
+Usage
+-----
- rankable_graph = RankableGraph.new
+ ```ruby
+ 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)
+ #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
+ 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
+ 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.
If you want to calculate the rank of another graph is recommended to call the clear method and reuse the RankableGraph instance as this frees the used memory without relying in the Ruby garbage collector.
So instead of:
- rankable_graph = RankableGraph.new
+ ```ruby
+ rankable_graph = RankableGraph.new
- rankable_graph.link(0, 1)
- rankable_graph.link(1, 2)
- rankable_graph.rank(0.85, 0.0001){ |identifier, rank| puts "Node #{identifier} rank for graph1 is #{rank}" }
+ rankable_graph.link(0, 1)
+ rankable_graph.link(1, 2)
+ rankable_graph.rank(0.85, 0.0001){ |identifier, rank| puts "Node #{identifier} rank for graph1 is #{rank}" }
- rankable_graph = RankableGraph.new
+ rankable_graph = RankableGraph.new
- rankable_graph.link(0, 1)
- rankable_graph.link(2, 1)
- rankable_graph.rank(0.85, 0.0001){ |identifier, rank| puts "Node #{identifier} rank for graph2 is #{rank}" }
+ rankable_graph.link(0, 1)
+ rankable_graph.link(2, 1)
+ rankable_graph.rank(0.85, 0.0001){ |identifier, rank| puts "Node #{identifier} rank for graph2 is #{rank}" }
+ ```
It's better if you do:
- rankable_graph = RankableGraph.new
+ ```ruby
+ rankable_graph = RankableGraph.new
- rankable_graph.link(0, 1)
- rankable_graph.link(1, 2)
- rankable_graph.rank(0.85, 0.0001){ |identifier, rank| puts "Node #{identifier} rank for graph1 is #{rank}" }
+ rankable_graph.link(0, 1)
+ rankable_graph.link(1, 2)
+ rankable_graph.rank(0.85, 0.0001){ |identifier, rank| puts "Node #{identifier} rank for graph1 is #{rank}" }
- rankable_graph.clear
+ rankable_graph.clear
- rankable_graph.link(0, 1)
- rankable_graph.link(2, 1)
- rankable_graph.rank(0.85, 0.0001){ |identifier, rank| puts "Node #{identifier} rank for graph2 is #{rank}" }
+ rankable_graph.link(0, 1)
+ rankable_graph.link(2, 1)
+ rankable_graph.rank(0.85, 0.0001){ |identifier, rank| puts "Node #{identifier} rank for graph2 is #{rank}" }
+ ```
For more examples please refer to the tests.
-== Requirements
+Requirements
+------------
* {glib2}[http://library.gnome.org/devel/glib/2.22/] >= 2.22.2
+
+ In Mac
+ ```bash
+ brew install glib
+ ```
+
+ In Linux
+ ```bash
+ sudo apt-get install libglib2.0-dev
+ ```
-== Note on Patches/Pull Requests
+Note on Patches/Pull Requests
+-----------------------------
* Fork the project.
* Make your feature addition or bug fix.
@@ -83,6 +104,7 @@ For more examples please refer to the tests.
(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
+---------
-Copyright (c) 2009 {Cubox}[http://cuboxsa.com]. See LICENSE for details.
+Copyright (c) 2012 [Cubox](http://cuboxlabs.com). See LICENSE for details.

0 comments on commit 166c10a

Please sign in to comment.