Class PageRankGaussSeidel
public class PageRankGaussSeidel extends PageRank
PageRankParallelGaussSeidel is faster and provides exact bounds via
vector norms.
The general formula described in PageRank can be rewritten as the following linear system:
The system
The normDelta() method returns 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).
Warning: Since we need to enumerate the predecessors a node, you must pass to the constructor the transpose of the graph.
Substituting to M and to b the corresponding terms present in the first formula, we obtain the following update rule:
We can rearrange the previous formula sums in two different sums: one for the nodes j → i and one for the dangling nodes (nondangling nodes that are not predecessors of i give no contribution). So the Gauß–Seidel method can be implemented as follows:
- initialize x as the uniform vector;
- while some stopping criterion has not been met,
- for all i = 0,1,…, N−1
- σ = 0;
- for all j → i, with j ≠ i, σ += pji xj
- for all dangling j, σ += ui xj
- xi = ( (1 − α) vi + ασ ) ⁄ (1 − αpii − αdiui)
- for all i = 0,1,…, N−1
Remember that ui is 1⁄n when the weakly preferential version of the PageRank formula is considered, vi when the version is the strongly preferential one.
The second “for all” can be avoided if we keep track of the summation of all ranks of dangling nodes up to index i (exclusive) and for all dangling nodes from index i on in two variables B (before i) and A (after i):
- initialize x as the uniform vector;
- B = 0;
- for all dangling j, A += xj;
- while some stopping criterion has not been met,
- for all i = 0,1,…,N−1
- σ = 0;
- for all j → i, with j ≠ i, σ += pji xj
- σ += (A + B − di xi) ui
- σ = ( (1 − α) vi + ασ ) ⁄ (1 − αpii − αdi ui)
- if i is dangling
- B += σ
- A −= xi
- xi = σ
- for all i = 0,1,…,N−1
- Author:
- Sebastiano Vigna
- See Also:
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 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 Modifier Constructor Description PageRankGaussSeidel(ImmutableGraph transpose)Creates a new instance.protectedPageRankGaussSeidel(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 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).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
-
pseudoRank
public boolean pseudoRankIf true, an everywhere zero dangling-node distribution will be simulated, resulting in the computation of a pseudorank.
-
-
Constructor Details
-
PageRankGaussSeidel
Creates a new instance.- Parameters:
transpose- the transpose of the graph on which to compute PageRank.logger- a logger that will be passed tosuper().
-
PageRankGaussSeidel
Creates a new instance.- Parameters:
transpose- the transpose of the graph on which to compute PageRank.
-
-
Method Details
-
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
-
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
-
normDelta
public double normDelta()Return 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 to the ℓ1 norm of the error.
-
step
public void step()Description copied from class:SpectralRankingPerforms one computation step.- Specified by:
stepin classSpectralRanking
-
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
-
main
public static void main(String[] arg) throws IOException, JSAPException, ClassNotFoundException, ConfigurationException
-