Class: PageRank

PageRank(A:, v:, tol:, d:, maxIt:)

Implementation of the Google PageRank Algorithm. To run it, create an instance with an adjacency matrix and call the `iterate` method on it.

Constructor

new PageRank(A:, v:, tol:, d:, maxIt:)

Instantiate a new PageRank object with an adjacency matrix
Parameters:
Name Type Description
A: Array.<Array.<Number>> Adjacency matrix.
v: Array.<Number> | null Distribution vector (if not specified, uniform over the nodes)
tol: Number The tolerance threshold for convergence.
d: Number Damping factor. Probability of transitioning to an adjacent node.
maxIt: Number Maximum iteration in case the algorithm doesn't converge.
Source:

Members

A :Array.<Array.<Number>>

Adjacency matrix.
Type:
  • Array.<Array.<Number>>
Source:

a :Array.<Number>

Array with binary dangling nodes vector.
Type:
  • Array.<Number>
Source:

alpha :Number

Alpha, probability of jumping to random node.
Type:
  • Number
Source:

d :Number

Damping factor. Probability of transitioning to an adjacent node.
Type:
  • Number
Source:

H :Array.<Array.<Number>>

Hyperlink matrix containing the weighted links between nodes.
Type:
  • Array.<Array.<Number>>
Source:

initProb :Number

Initial probability.
Type:
  • Number
Source:

maxIt :Number

The maximum number of iterations
Type:
  • Number
Source:

pageCount :Number

Number of pages in the adjacency matrix.
Type:
  • Number
Source:

result

Contains result of ranking.
Source:

tol :Number

The tolerance threshold for convergence.
Type:
  • Number
Source:

v :Array.<Number>

General distribution vector (uniform over the nodes if not specified).
Type:
  • Array.<Number>
Source:

Methods

(static) detectDangling(adjacency) → {Array.<Number>}

Detect dangling nodes in the adjacency matrix and return them in an array where 0 means the node is non-dangling and 1 means the node is dangling.
Parameters:
Name Type Description
adjacency Array.<Array.<Number>> Adjacency matrix
Source:
Returns:
Type
Array.<Number>

(static) fromAdjacencyList(v:, tol:, d:, maxIt:)

Create PageRank instance from Adjacency List. * @param {Array>} adjacencyList: Adjacency List.
Parameters:
Name Type Description
v: Array.<Number> | null Distribution vector (if not specified, uniform over the nodes)
tol: Number The tolerance threshold for convergence.
d: Number Damping factor. Probability of transitioning to an adjacent node.
maxIt: Number Maximum iteration in case the algorithm doesn't converge.
Source:

(static) fromAdjacencyMatrix(adjacency:, v:, tol:, d:, maxIt:)

Create PageRank instance from Adjacency Matrix (same as constructor).
Parameters:
Name Type Description
adjacency: Array.<Array.<Number>> Adjacency matrix.
v: Array.<Number> | null Distribution vector (if not specified, uniform over the nodes)
tol: Number The tolerance threshold for convergence.
d: Number Damping factor. Probability of transitioning to an adjacent node.
maxIt: Number Maximum iteration in case the algorithm doesn't converge.
Source:

(static) fromEdgeList(edgeList:, v:, tol:, d:, maxIt:)

Create PageRank instance from Edge List. Edge List ist array of arrays of length two where each inner array defines an edge between two nodes. e.g. [[0, 1], []]
Parameters:
Name Type Description
edgeList: Array.<Array.<Number>> Edge List from which to build the adjacency matrix
v: Array.<Number> | null Distribution vector (if not specified, uniform over the nodes)
tol: Number The tolerance threshold for convergence.
d: Number Damping factor. Probability of transitioning to an adjacent node.
maxIt: Number Maximum iteration in case the algorithm doesn't converge.
Source:

(static) getMappedResults(pi, nameMap) → {Object.<string, Number>}

Map the results of a pi vector to the names in a nameMap.
Parameters:
Name Type Description
pi Array.<Number> Results of PageRank
nameMap Object.<string, Number> Keys are name of node, values are index in pi
Source:
Returns:
keys are name of node, values are ranking
Type
Object.<string, Number>

(static) makeMatrixH(adjacency:) → {Array.<Array.<Number>>}

Convert an adjacency matrix into an H (hyperlink) matrix.
Parameters:
Name Type Description
adjacency: Array.<Array.<Number>> The adjacency matrix to convert.
Source:
Returns:
Type
Array.<Array.<Number>>

iterate(nameMap) → {Object}

Perform the Power Method iterations of the algorithm.
Parameters:
Name Type Default Description
nameMap Object.<string, Number> | null null optional. Keys are node names, values are index in adjacency matrix.
Source:
Returns:
- Contains the resulting array, number of iterations, and whether the algorithm converged
Type
Object