Class PageRankParallelGaussSeidel
public class PageRankParallelGaussSeidel extends PageRank
Note: this is the implementation of choice to be used when computing PageRank. It uses less memory (one vector of doubles plus one vector of integers) and, experimentally, converges faster than any other implementation. Moreover, it scales linearly with the number of cores.
Warning: Since we need to enumerate the predecessors a node, you must pass to the constructor the transpose of the graph.
Technically, the iteration performed by this class is not a Gauß–Seidel iteration: we simply start a number of threads, and each thread updates a value using a Gauß–Seidel-like rule. As a result, each update uses some old and some new values: in other words, the regular splitting
Note that the step() method is not available: due to the need for some synchronization logic, only stepUntil(StoppingCriterion)
is available.
The normDelta() method returns the following values:
- if a suitable norm vector has been set, an upper bound on the error (the ℓ∞ distance from the rank to be computed);
- otherwise, an upper bound to the ℓ1 norm of the error, obtained multiplying by α / (1 − α) the ℓ1 norm of the difference between the last two approximations (this idea arose in discussions with David Gleich).
To be able to set a norm vector, you need to set the pseudoRank flag and use PowerSeries
(setting the Markovian flag) to compute a suitable vector.
To do so, you must provide an α and use the PowerSeries.MAX_RATIO_STOPPING_CRITERION. If the computation
terminates without errors with maximum ratio σ, the resulting vector can be used
with this class to compute pseudoranks for all α < 1 / σ (strictness
is essential). Note that the ℓ1 norm of the error bounds the ℓ∞.
With respect to the description of the exact algorithm in PageRankGaussSeidel, we operate a simplification that is
essentially in obtaining a coherent update without incurring in too much synchronization: the rank associated with
dangling nodes is computed at the end of each computation, and used unchanged throughout the whole iteration. This corresponds to
permuting the array so that dangling nodes come out last.
- Author:
- Sebastiano Vigna
- See Also:
PageRankGaussSeidel,PageRank,SpectralRanking
-
Nested Class Summary
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 int[]outdegreeThe outdegree of each node (initialized after the first computation).booleanpseudoRankIf true, an everywhere zero dangling-node distribution will be simulated, resulting in the computation of a pseudorank.Fields inherited from class it.unimi.dsi.law.rank.PageRank
alpha, buckets, danglingNodeDistribution, DEFAULT_ALPHA, preference, stronglyPreferentialFields 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 Constructor Description PageRankParallelGaussSeidel(ImmutableGraph transpose)Creates a new instance.PageRankParallelGaussSeidel(ImmutableGraph transpose, int requestedThreads, Logger logger)Creates a new instance.PageRankParallelGaussSeidel(ImmutableGraph transpose, Logger logger)Creates a new instance. -
Method Summary
Modifier and Type Method Description voidclear()Clears all data and releases resources by nullingSpectralRanking.rank(i.e., results we no longer be available).voidinit()Basic initialization: we log the damping factor, check that the preference vector is correctly sized and stochastic, fillSpectralRanking.rankwith the preference vector and set the dangling-node distribution depending on the value ofPageRank.stronglyPreferential.static voidmain(String[] arg)doublenormDelta()Return the following values: if a suitable norm vector has been set, an upper bound on the error (the ℓ∞ distance from the rank to be computed); otherwise, an upper bound to the ℓ1 norm of the error, obtained multiplying by α / (1 − α) the ℓ1 norm of the difference between the last two approximations (this idea arose in discussions with David Gleich).voidnormVector(double[] normVector, double sigma)Sets the norm vector.voidnormVector(String normVectorFilename, double sigma)Sets the norm vector.voidstep()Performs one computation step.voidstepUntil(SpectralRanking.StoppingCriterion stoppingCriterion)CallsSpectralRanking.init()and steps until a given stopping criterion is met.Methods inherited from class it.unimi.dsi.law.rank.PageRank
buildPropertiesMethods inherited from class it.unimi.dsi.law.rank.SpectralRanking
and, approximateNormVector, buildProperties, isStochastic, or
-
Field Details
-
outdegree
public int[] outdegreeThe outdegree of each node (initialized after the first computation). -
pseudoRank
public boolean pseudoRankIf true, an everywhere zero dangling-node distribution will be simulated, resulting in the computation of a pseudorank.
-
-
Constructor Details
-
PageRankParallelGaussSeidel
Creates a new instance.- Parameters:
transpose- the transpose of the graph on which to compute PageRank.requestedThreads- the requested number of threads (0 forRuntime.availableProcessors()).logger- a logger that will be passed tosuper().
-
PageRankParallelGaussSeidel
Creates a new instance.- Parameters:
transpose- the transpose of the graph on which to compute PageRank.
-
PageRankParallelGaussSeidel
Creates a new instance.- Parameters:
transpose- the transpose of the graph on which to compute PageRank.logger- a logger that will be passed tosuper().
-
-
Method Details
-
normVector
Sets the norm vector.- Parameters:
normVectorFilename- a file containing a norm vector as a list of doubles inDataInputformat, ornullfor no norm vector.sigma- the value for which the provided norm vector is suitable.- Throws:
IOException
-
normVector
public void normVector(double[] normVector, double sigma)Sets the norm vector.- Parameters:
normVector- the new norm vector.sigma- the value for which the provided norm vector is suitable.
-
init
Description copied from class:PageRankBasic initialization: we log the damping factor, check that the preference vector is correctly sized and stochastic, fillSpectralRanking.rankwith the preference vector and set the dangling-node distribution depending on the value ofPageRank.stronglyPreferential.- Overrides:
initin classPageRank- Throws:
IOException
-
step
Description copied from class:SpectralRankingPerforms one computation step.- Specified by:
stepin classSpectralRanking- Throws:
IOException
-
stepUntil
Description copied from class:SpectralRankingCallsSpectralRanking.init()and steps until a given stopping criterion is met. The criterion is checked a posteriori (i.e., after each step); this means that at least one step is performed.- Overrides:
stepUntilin classSpectralRanking- Parameters:
stoppingCriterion- the stopping criterion to be used.- Throws:
IOException
-
normDelta
public double normDelta()Return the following values: if a suitable norm vector has been set, an upper bound on the error (the ℓ∞ distance from the rank to be computed); otherwise, an upper bound to the ℓ1 norm of the error, obtained multiplying by α / (1 − α) the ℓ1 norm of the difference between the last two approximations (this idea arose in discussions with David Gleich).- Overrides:
normDeltain classSpectralRanking- Returns:
- an upper bound on the error.
-
clear
public void clear()Description copied from class:SpectralRankingClears 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:
clearin classSpectralRanking
-
main
public static void main(String[] arg) throws IOException, JSAPException, ClassNotFoundException, ConfigurationException
-