Class LeftSingularVectorParallelPowerMethod
public class LeftSingularVectorParallelPowerMethod extends SpectralRanking
This class computes iteratively and in parallel an approximation of the left singular vector of a graph
with adjacency matrix M, that is, the dominant eigenvector of MMT.
Note that the step() method is not available: due to the need for some synchronization logic, only stepUntil(StoppingCriterion)
is available.
This class can be run using SpectralRanking.NormStoppingCriterion that stops, as usual, when normDelta(),
which returns the norm of the difference between the two last approximations,
is below a specified threshold.
It is strongly suggested that you apply a shift (e.g., -1). A negative shift guarantees convergence even in the presence of eigenvalues of maximum modulus that are not real positive (see a numerical linear algebra textbook for details).
- Author:
- Sebastiano Vigna
-
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[]intermediateRankThe rank vector obtained after the first half of a round.NormnormThe norm.double[]previousRankThe rank vector at the end of the last round.booleansalsaCompute the SALSA score (only for historical and testing reasons: please use theSalsaclass instead).doubleshiftA shift.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 LeftSingularVectorParallelPowerMethod(ImmutableGraph graph, ImmutableGraph transpose)Creates a new instance.LeftSingularVectorParallelPowerMethod(ImmutableGraph graph, ImmutableGraph transpose, int requestedThreads)Creates a new instance.LeftSingularVectorParallelPowerMethod(ImmutableGraph graph, ImmutableGraph transpose, int requestedThreads, Logger logger)Creates a new instance.LeftSingularVectorParallelPowerMethod(ImmutableGraph graph, ImmutableGraph transpose, Logger logger)Creates a new instance. -
Method Summary
Modifier and Type Method Description PropertiesbuildProperties(String graphBasename)Returns a Properties object that contains all the parameters used by the computation.voidclear()Clears all data and releases resources by nullingSpectralRanking.rank(i.e., results we no longer be available).voidinit()Initializes the rank vector, zeroesSpectralRanking.iterationand logs basic data.static voidmain(String[] arg)doublenormDelta()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.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.SpectralRanking
and, approximateNormVector, isStochastic, or
-
Field Details
-
norm
The norm. -
salsa
public boolean salsaCompute the SALSA score (only for historical and testing reasons: please use theSalsaclass instead). -
shift
public double shiftA shift. -
intermediateRank
public double[] intermediateRankThe rank vector obtained after the first half of a round. -
previousRank
public double[] previousRankThe rank vector at the end of the last round.
-
-
Constructor Details
-
LeftSingularVectorParallelPowerMethod
public LeftSingularVectorParallelPowerMethod(ImmutableGraph graph, ImmutableGraph transpose, int requestedThreads, Logger logger)Creates a new instance.- Parameters:
graph- the graph on which the computation must be performed.transpose- the tranpose of the graph on which the computation must be performed.requestedThreads- the requested number of threads (0 forRuntime.availableProcessors()).logger- a logger that will be passed tosuper().
-
LeftSingularVectorParallelPowerMethod
public LeftSingularVectorParallelPowerMethod(ImmutableGraph graph, ImmutableGraph transpose, Logger logger)Creates a new instance.- Parameters:
graph- the graph on which the computation must be performed.transpose- the tranpose of the graph on which the computation must be performed.logger- a logger that will be passed tosuper().
-
LeftSingularVectorParallelPowerMethod
public LeftSingularVectorParallelPowerMethod(ImmutableGraph graph, ImmutableGraph transpose, int requestedThreads)Creates a new instance.- Parameters:
graph- the graph on which the computation must be performed.transpose- the tranpose of the graph on which the computation must be performed.requestedThreads- the requested number of threads (0 forRuntime.availableProcessors()).
-
LeftSingularVectorParallelPowerMethod
Creates a new instance.- Parameters:
graph- the graph on which the computation must be performed.transpose- the tranpose of the graph on which the computation must be performed.
-
-
Method Details
-
init
Description copied from class:SpectralRankingInitializes the rank vector, zeroesSpectralRanking.iterationand logs basic data. Please extend this method to handle additional attributes.- Overrides:
initin classSpectralRanking- 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()Description copied from class:SpectralRankingReturns 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:
normDeltain classSpectralRanking- Returns:
- the norm of an estimation of the distance to the limit.
-
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
-
buildProperties
Returns a Properties object that contains all the parameters used by the computation.- Overrides:
buildPropertiesin classSpectralRanking- Parameters:
graphBasename- file name of the graph- Returns:
- a properties object that represent all the parameters used to calculate the rank.
-
main
-