Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Haifengl Smile PageRank

From Leeroopedia
Revision as of 15:04, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Haifengl_Smile_PageRank.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Graph Analysis, Link Analysis, Linear Algebra
Last Updated 2026-02-08 22:00 GMT

Overview

PageRank is an interface providing static methods to compute the PageRank vector of a graph using the power iteration method.

Description

The PageRank interface in the smile.math package implements the PageRank link analysis algorithm, which assigns a numerical weighting to each element of a hyperlinked set of documents. The implementation uses the power iteration method to iteratively compute the stationary distribution of a random walk on the graph.

The algorithm supports:

  • Default uniform teleportation -- all nodes have equal teleportation probability (1/n)
  • Custom teleportation vector -- allows personalized PageRank computation
  • Configurable damping factor -- controls the probability of following links vs. teleporting (default: 0.85)
  • Convergence tolerance -- the algorithm stops when the L1 change between iterations falls below the tolerance

Usage

Use PageRank when you need to rank nodes in a directed graph by importance, such as ranking web pages, computing influence in social networks, or ordering items in a citation graph.

Code Reference

Source Location

Signature

public interface PageRank {
    // PageRank with uniform teleportation
    static Vector of(Matrix A);

    // PageRank with custom teleportation vector
    static Vector of(Matrix A, Vector v);

    // PageRank with full control over parameters
    static Vector of(Matrix A, Vector v,
                     double damping, double tol, int maxIter);
}

Import

import smile.math.PageRank;

I/O Contract

Inputs

Name Type Required Description
A Matrix Yes A square matrix representing the link structure (must support matrix-vector multiplication)
v Vector No The teleportation vector (default: uniform 1/n for all nodes)
damping double No The damping factor, probability of following a link (default: 0.85)
tol double No The desired convergence tolerance (default: 1E-7)
maxIter int No The maximum number of power iterations (default: 57)

Outputs

Name Type Description
pagerank Vector The PageRank vector where each entry represents the importance score of the corresponding node

Usage Examples

Basic PageRank

// Create an adjacency/transition matrix A
Matrix A = ...; // n x n column-stochastic matrix
Vector ranks = PageRank.of(A);
// ranks[i] gives the PageRank score of node i

Personalized PageRank

Matrix A = ...; // transition matrix
int n = A.nrow();
Vector v = A.vector(n);
// Set personalized teleportation probabilities
v.set(0, 0.5);
v.set(1, 0.3);
v.set(2, 0.2);

Vector ranks = PageRank.of(A, v);

Custom Parameters

Matrix A = ...;
Vector v = ...;
double damping = 0.90;
double tolerance = 1E-10;
int maxIterations = 200;

Vector ranks = PageRank.of(A, v, damping, tolerance, maxIterations);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment