@graphty/algorithms
Version:
Graph algorithms library for browser environments implemented in TypeScript
80 lines • 2.54 kB
TypeScript
import type { Graph } from "../../core/graph.js";
import type { NodeId } from "../../types/index.js";
/**
* Delta-based PageRank implementation for faster convergence
*
* This algorithm tracks changes (deltas) between iterations and only processes
* nodes with significant changes, dramatically reducing computation for graphs
* where only some nodes are actively changing their PageRank values.
*
* Key optimizations:
* - Only active nodes (with significant deltas) are processed
* - Early termination for converged vertices
* - Priority queue processing for high-impact updates
* - Adaptive convergence detection per vertex
*
* Expected speedup: 10-100x for incremental updates on large graphs
*/
export interface DeltaPageRankOptions {
/**
* Damping factor (probability of following a link) (default: 0.85)
*/
dampingFactor?: number;
/**
* Convergence tolerance (default: 1e-6)
*/
tolerance?: number;
/**
* Maximum number of iterations (default: 100)
*/
maxIterations?: number;
/**
* Minimum delta to keep vertex active (default: tolerance / 10)
*/
deltaThreshold?: number;
/**
* Personalization vector for Personalized PageRank (default: null)
*/
personalization?: Map<NodeId, number>;
/**
* Weight attribute for weighted PageRank (default: null = unweighted)
*/
weight?: string;
}
export declare class DeltaPageRank {
private graph;
private scores;
private deltas;
private activeNodes;
private outDegrees;
private outWeights;
private danglingNodes;
private nodeCount;
constructor(graph: Graph);
private initialize;
compute(options?: DeltaPageRankOptions): Map<NodeId, number>;
/**
* Update PageRank scores after graph modification
* This is where delta-based approach really shines
*/
update(modifiedNodes: Set<NodeId>, options?: DeltaPageRankOptions): Map<NodeId, number>;
private normalizeMap;
}
/**
* Priority queue based implementation for even better performance
* Processes nodes in order of their delta magnitude
*/
export declare class PriorityDeltaPageRank {
private graph;
private scores;
private priorityQueue;
private nodeDeltas;
private outWeights;
private danglingNodes;
private nodeCount;
constructor(graph: Graph);
private initialize;
computeWithPriority(options?: DeltaPageRankOptions): Map<NodeId, number>;
private normalizeMap;
}
//# sourceMappingURL=delta-pagerank.d.ts.map