Class: PageRank::SparseNative

Inherits:
Base
  • Object
show all
Defined in:
lib/page_rank/sparse_native.rb

Instance Attribute Summary

Attributes inherited from Base

#damping, #tolerance

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from PageRank::Base

Instance Method Details

#add(source, dest, weight: 1.0) ⇒ nil

Parameters:

  • weight (Float) (defaults to: 1.0)

    Optional weight for the graph edge

  • _source (Object)

    The source node

  • _dest (Object)

    The destination node

Returns:

  • (nil)


9
10
11
# File 'lib/page_rank/sparse_native.rb', line 9

def add(source, dest, weight: 1.0)
  _add_edge(source, dest, weight) unless source == dest
end

#calculate(max_iterations: -1,, **_) ⇒ Hash<Object, Float>

Perform the PageRank calculation

Parameters:

  • max_iterations (Fixnum) (defaults to: -1,)

    Maximum number of PageRank iterations to perform (or -1 for no max)

Returns:

  • (Hash<Object, Float>)

    of nodes with rank



16
17
18
# File 'lib/page_rank/sparse_native.rb', line 16

def calculate(max_iterations: -1, **_)
  _calculate(max_iterations, damping, tolerance)
end