Giter Site home page Giter Site logo

pagerank's Introduction

Build Status endorse

pagerank

A Go language PageRank implementation.

Description

A library to calculate the PageRank of a big directed graph. It's intended to be used for big but not huge graphs, as those are better processed with a map-reduce distributed solution. This is a port from ruby's rankable_graph gem.

Usage

package main

import "github.com/dcadenas/pagerank"
import "fmt"

func main(){
  graph := pagerank.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.
  graph.Link(1234, 4312)
  graph.Link(9876, 4312)
  graph.Link(4312, 9876)
  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

  graph.Rank(probability_of_following_a_link, tolerance, func(identifier int, rank float64) {
    fmt.Println("Node", identifier, "rank is", rank)
  })
}

Which outputs

Node 1234 rank is 0.03750000000000001
Node 4312 rank is 0.4797515116401361
Node 9876 rank is 0.44524848835986397
Node 8888 rank is 0.03750000000000001

This ranks represent the probabilities that a certain node will be visited.

For more examples please refer to the tests.

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

Author: Daniel Cadenas

Copyright (c) 2013. See LICENSE for details.

pagerank's People

Contributors

dcadenas avatar

Watchers

Robert Fielding avatar James Cloos avatar  avatar

Forkers

uikit0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.