Class KatzParallelGaussSeidel
public class KatzParallelGaussSeidel extends SpectralRanking
Warning: Since we need to enumerate the predecessors a node, you must pass to the constructor the transpose of the graph.
This class approximates the infinite summation
step()
method is not available: due to the need for some synchronization logic, only stepUntil(StoppingCriterion)
is available.
Technically, the iteration performed by this class is a step-asynchronous 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
normDelta()
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 estimate of the ℓ∞ norm of the residual obtained by multiplying the ℓ∞ norm of the difference between the last two approximations by the ℓ∞ norm of αG (i.e., the maximum indegree multiplied by α).
To be able to set a norm vector, you need to use PowerSeries
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 for all α < 1 / σ (strictness
is essential). Note that this is the only way to obtain a bound on the error (unless
your graph is so small that you can evaluate the ℓ∞ norm of (1 − αG)-1 and use it to bound the error using the residual).
Details about the method are described by Sebastiano Vigna in “Supremum-Norm Convergence for Step-Asynchronous Successive Overrelaxation on M-matrices“, 2014.
- Author:
- Sebastiano Vigna
- See Also:
PageRank
,SpectralRanking
,PowerSeries
-
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 double
alpha
The attenuation factor.DoubleList
preference
The preference vector to be used (ornull
if the uniform preference vector should be used).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 Constructor Description KatzParallelGaussSeidel(ImmutableGraph transpose)
Creates a new instance.KatzParallelGaussSeidel(ImmutableGraph transpose, int requestedThreads, Logger logger)
Creates a new instance. -
Method Summary
Modifier and Type Method Description Properties
buildProperties(String graphBasename, String preferenceFilename)
Returns a Properties object that contains all the parameters used by the computation.void
init()
Initializes the rank vector, zeroesSpectralRanking.iteration
and logs basic data.static void
main(String[] arg)
double
normDelta()
Returns the norm of an estimation of the distance to the limit of the iterative process: depending on the implementation, this can be an actual bound or, for example, just the difference between the last two approximations.void
normVector(double[] normVector, double sigma)
Sets the norm vector.void
normVector(String normVectorFilename, double sigma)
Sets the norm vector.void
step()
Performs one computation step.void
stepUntil(SpectralRanking.StoppingCriterion stoppingCriterion)
CallsSpectralRanking.init()
and steps until a given stopping criterion is met.Methods inherited from class it.unimi.dsi.law.rank.SpectralRanking
and, approximateNormVector, buildProperties, clear, isStochastic, or
-
Field Details
-
alpha
public double alphaThe attenuation factor. Must be smaller than the reciprocal of the dominant eigenvalue. -
preference
The preference vector to be used (ornull
if the uniform preference vector should be used).
-
-
Constructor Details
-
KatzParallelGaussSeidel
Creates a new instance.- Parameters:
transpose
- the transpose of the graph on which to compute Katz's index.requestedThreads
- the requested number of threads (0 forRuntime.availableProcessors()
).logger
- a logger that will be passed tosuper()
.
-
KatzParallelGaussSeidel
Creates a new instance.- Parameters:
transpose
- the transpose of the graph on which to compute Katz's index.
-
-
Method Details
-
normVector
Sets the norm vector.- Parameters:
normVectorFilename
- a file containing a norm vector as a list of doubles inDataInput
format, ornull
for 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:SpectralRanking
Initializes the rank vector, zeroesSpectralRanking.iteration
and logs basic data. Please extend this method to handle additional attributes.- Overrides:
init
in classSpectralRanking
- Throws:
IOException
-
step
Description copied from class:SpectralRanking
Performs one computation step.- Specified by:
step
in classSpectralRanking
- Throws:
IOException
-
stepUntil
Description copied from class:SpectralRanking
CallsSpectralRanking.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:
stepUntil
in classSpectralRanking
- Parameters:
stoppingCriterion
- the stopping criterion to be used.- Throws:
IOException
-
normDelta
public double normDelta()Description copied from class:SpectralRanking
Returns the norm of an estimation of the distance to the limit of the iterative process: depending on the implementation, this can be an actual bound or, for example, just the difference between the last two approximations.This method must be implemented by concrete subclasses if you want to use
SpectralRanking.NormStoppingCriterion
.- Overrides:
normDelta
in classSpectralRanking
- Returns:
- the norm of an estimation of the distance to the limit.
-
buildProperties
Returns a Properties object that contains all the parameters used by the computation.- Parameters:
graphBasename
- file name of the graphpreferenceFilename
- file name of preference vector. It can benull
.- Returns:
- a properties object that represent all the parameters used to calculate the rank.
-
main
public static void main(String[] arg) throws IOException, JSAPException, ClassNotFoundException, ConfigurationException
-