Class PageRankPush
public class PageRankPush extends PageRank
The push algorithm is an incremental way of computing PageRank that is particularly useful when the preference vector is nonzero on a single node, the root (i.e., the entire probability mass of the preference vector is in a single node). It was first proposed by Glen Jeh and Jennifer Widom in “Scaling personalized web search”, Proc. of the Twelfth International World Wide Web Conference, pages 271−279, ACM Press, 2003.
This implementation, in particular, computes strongly preferential PageRank for a single root node (i.e., dangling nodes donate all their rank to the root).
Since often the set of nodes involved in the computation is a small fraction, we represent implicitly such nodes using their discovery order. As a result,
the SpectralRanking.rank
vector does not contain the ranks, which can be recovered using the following code instead:
double[] rank = new double[graph.numNodes()]; for(int i = pageRank.node2Seen.size(); i-- != 0;) rank[pageRank.seen2Node[i]] = pageRank.rank[i] / pageRank.pNorm;
In case you are interested in the pseudorank, instead, you should use
double[] rank = new double[graph.numNodes()]; for(int i = pageRank.node2Seen.size(); i-- != 0;) rank[pageRank.seen2Node[i]] = pageRank.rank[i] / (1 - pageRank.backToRoot);
Details on the push algorithm have been given by Paolo Boldi and Sebastiano Vigna in “The Push Algorithm for Spectral Ranking”. We implement both a priority-based update rule, and a simple FIFO update rule. Moreover, we implement loop elimination at the root, as described by Pavel Berkhin in “Bookmark-coloring approach to personalized PageRank computing”, Internet Math., 3(1):41−62, 2006.
- Author:
- Sebastiano Vigna
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PageRankPush.EmptyQueueStoppingCritertion
static class
PageRankPush.IntHeapIndirectPriorityQueue
static class
PageRankPush.L1NormStoppingCritertion
Nested classes/interfaces inherited from class it.unimi.dsi.law.rank.SpectralRanking
SpectralRanking.IterationNumberStoppingCriterion, SpectralRanking.NormStoppingCriterion, SpectralRanking.StoppingCriterion
-
Field Summary
Fields Modifier and Type Field Description double
backToRoot
The amount of ranking going back to the root.Int2IntOpenHashMap
node2Seen
A map from nodes to the seen-order.double
pNorm
The norm of theSpectralRanking.rank
.ProgressLogger
progressLogger
A progress logger.double[]
residual
The vector r (the rôole of p is covered bySpectralRanking.rank
).int
root
The node where the preference vector is concentrated.int[]
seen2Node
A map from seen-order to nodes.double
threshold
The threshold for stopping.Fields inherited from class it.unimi.dsi.law.rank.PageRank
alpha, buckets, danglingNodeDistribution, DEFAULT_ALPHA, preference, stronglyPreferential
Fields inherited from class it.unimi.dsi.law.rank.SpectralRanking
DEFAULT_MAX_ITER, DEFAULT_NORM, DEFAULT_THRESHOLD, graph, iteration, logger, n, rank, STOCHASTIC_TOLERANCE
-
Constructor Summary
Constructors Modifier Constructor Description PageRankPush(ImmutableGraph graph, boolean fifo)
Creates a new instance.protected
PageRankPush(ImmutableGraph graph, Logger logger, boolean fifo)
Creates a new instance. -
Method Summary
Modifier and Type Method Description void
clear()
Clears all data and releases resources by nullingSpectralRanking.rank
(i.e., results we no longer be available).void
init()
Basic initialization: we log the damping factor, check that the preference vector is correctly sized and stochastic, fillSpectralRanking.rank
with the preference vector and set the dangling-node distribution depending on the value ofPageRank.stronglyPreferential
.static void
main(String[] arg)
boolean
queueIsEmpty()
void
step()
Performs one computation step.Methods inherited from class it.unimi.dsi.law.rank.PageRank
buildProperties
Methods inherited from class it.unimi.dsi.law.rank.SpectralRanking
and, approximateNormVector, buildProperties, isStochastic, normDelta, or, stepUntil
-
Field Details
-
progressLogger
A progress logger. -
root
public int rootThe node where the preference vector is concentrated. -
threshold
public double thresholdThe threshold for stopping. -
residual
public double[] residualThe vector r (the rôole of p is covered bySpectralRanking.rank
). -
pNorm
public double pNormThe norm of theSpectralRanking.rank
. -
node2Seen
A map from nodes to the seen-order. -
seen2Node
public int[] seen2NodeA map from seen-order to nodes. -
backToRoot
public double backToRootThe amount of ranking going back to the root.
-
-
Constructor Details
-
PageRankPush
Creates a new instance.- Parameters:
graph
- the graph on which to compute PageRank.logger
- a logger that will be passed tosuper()
.fifo
- whether to use a FIFO queue instead of a priority queue to choose the next node to update.
-
PageRankPush
Creates a new instance.- Parameters:
graph
- the graph on which to compute PageRank.fifo
- whether to use a FIFO queue instead of a priority queue to choose the next node to update.
-
-
Method Details
-
clear
public void clear()Description copied from class:SpectralRanking
Clears all data and releases resources by nullingSpectralRanking.rank
(i.e., results we no longer be available). Please extend this method to handle additional attributes.- Overrides:
clear
in classSpectralRanking
-
init
Description copied from class:PageRank
Basic initialization: we log the damping factor, check that the preference vector is correctly sized and stochastic, fillSpectralRanking.rank
with the preference vector and set the dangling-node distribution depending on the value ofPageRank.stronglyPreferential
.- Overrides:
init
in classPageRank
- Throws:
IOException
-
step
public void step()Description copied from class:SpectralRanking
Performs one computation step.- Specified by:
step
in classSpectralRanking
-
queueIsEmpty
public boolean queueIsEmpty() -
main
-