
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
{}[http://travis-ci.org/cubox/rankable_graph]
= rankable_graph
A Ruby {PageRank}[http://en.wikipedia.org/wiki/PageRank] like implementation.
{}[http://en.wikipedia.org/wiki/PageRank]
== 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.
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
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.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
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.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
== Note on Patches/Pull Requests
== Copyright
Copyright (c) 2009 {Cubox}[http://cuboxsa.com]. See LICENSE for details.
FAQs
Unknown package
We found that rankable_graph demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.