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. |
Members
A :Array.<Array.<Number>>
Adjacency matrix.
Type:
- Array.<Array.<Number>>
a :Array.<Number>
Array with binary dangling nodes vector.
Type:
- Array.<Number>
alpha :Number
Alpha, probability of jumping to random node.
Type:
- Number
d :Number
Damping factor. Probability of transitioning to an adjacent node.
Type:
- Number
H :Array.<Array.<Number>>
Hyperlink matrix containing the weighted links between nodes.
Type:
- Array.<Array.<Number>>
initProb :Number
Initial probability.
Type:
- Number
maxIt :Number
The maximum number of iterations
Type:
- Number
pageCount :Number
Number of pages in the adjacency matrix.
Type:
- Number
result
Contains result of ranking.
tol :Number
The tolerance threshold for convergence.
Type:
- Number
v :Array.<Number>
General distribution vector (uniform over the nodes if not specified).
Type:
- Array.<Number>
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 |
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. |
(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. |
(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. |
(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 |
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. |
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. |
Returns:
- Contains the resulting array, number of iterations, and whether the algorithm converged
- Type
- Object