es.yrbcn.graph.weighted
Class WeightedPageRankPowerMethod

java.lang.Object
  extended by es.yrbcn.graph.weighted.WeightedPageRank
      extended by es.yrbcn.graph.weighted.WeightedPageRankPowerMethod

public class WeightedPageRankPowerMethod
extends WeightedPageRank

Computes PageRank using the Power Method.

The Power Method computes the principal eigenvector of a matrix M starting from an (arbitrary) vector x(0) and iterating the computation

(x(t+1))' = (x(t))' M

Note that

(x(t+1))' = (x(t))' M = (x(t))' (α P + α du' + (1−α)1 v') = α(x(t))' P + α (x(t))'d u' + (1−α) v'.
The latter formula means that
xi(t+1)= αΣji pjixj(t) + ακui + (1−α)vi
where κ is the sum of xj(t) over all dangling nodes. This is the formula used in the code.

The attribute previousRank represents the ranking at the previous step.


Nested Class Summary
 
Nested classes/interfaces inherited from class es.yrbcn.graph.weighted.WeightedPageRank
WeightedPageRank.IterationNumberStoppingCriterion, WeightedPageRank.Norm, WeightedPageRank.NormDeltaStoppingCriterion, WeightedPageRank.StoppingCriterion
 
Field Summary
 String coeffBasename
          If not null, the basename for coefficents.
 double[][] derivative
          The value of derivatives (only for the subset of nodes specified in subset, if not null).
 int[] order
          The order of the derivatives.
 double[] previousRank
          The rank vector after the last iteration (only meaningful after at least one step).
protected  it.unimi.dsi.logging.ProgressLogger progressLogger
          A progress logger.
 int[] subset
          If not null, the subset of nodes over which the derivatives should be computed.
 
Fields inherited from class es.yrbcn.graph.weighted.WeightedPageRank
alpha, buckets, DEFAULT_ALPHA, DEFAULT_MAX_ITER, DEFAULT_THRESHOLD, g, iterationNumber, logger, norm, numNodes, preference, preferentialAdjustment, rank, start, STOCHASTIC_TOLERANCE, stronglyPreferential, sumoutweight
 
Constructor Summary
WeightedPageRankPowerMethod(ArcLabelledImmutableGraph g)
          Creates a new PageRank Power-Method based calculator.
WeightedPageRankPowerMethod(ArcLabelledImmutableGraph g, org.apache.log4j.Logger logger)
          Creates a new PageRank Power–Method based calculator.
 
Method Summary
 void clear()
          Clears all data.
 void init()
          Initializes the variables for PageRank computation.
static void main(String[] arg)
           
 double normDelta()
          Returns a norm of the difference with the previous step rank vector.
 void step()
          Computes the next step of the Power Method.
 void stepUntil(WeightedPageRank.StoppingCriterion stoppingCriterion)
          Calls WeightedPageRank.init() and steps until a given stopping criterion is met.
 
Methods inherited from class es.yrbcn.graph.weighted.WeightedPageRank
and, buildProperties, isStochastic, or
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

previousRank

public double[] previousRank
The rank vector after the last iteration (only meaningful after at least one step).


progressLogger

protected final it.unimi.dsi.logging.ProgressLogger progressLogger
A progress logger.


subset

public int[] subset
If not null, the subset of nodes over which the derivatives should be computed.


derivative

public double[][] derivative
The value of derivatives (only for the subset of nodes specified in subset, if not null).


order

public int[] order
The order of the derivatives. Must be non-null, but it can be the empty array.


coeffBasename

public String coeffBasename
If not null, the basename for coefficents.

Constructor Detail

WeightedPageRankPowerMethod

public WeightedPageRankPowerMethod(ArcLabelledImmutableGraph g,
                                   org.apache.log4j.Logger logger)
Creates a new PageRank Power–Method based calculator.

Parameters:
g - the graph.
logger - a logger that will be passed to super().

WeightedPageRankPowerMethod

public WeightedPageRankPowerMethod(ArcLabelledImmutableGraph g)
Creates a new PageRank Power-Method based calculator.

Parameters:
g - the graph.
Method Detail

init

public void init()
          throws IOException
Description copied from class: WeightedPageRank
Initializes the variables for PageRank computation.

This method initialises the starting vector

Overrides:
init in class WeightedPageRank
Throws:
IOException

step

public void step()
          throws IOException
Computes the next step of the Power Method.

Specified by:
step in class WeightedPageRank
Throws:
IOException

stepUntil

public void stepUntil(WeightedPageRank.StoppingCriterion stoppingCriterion)
               throws IOException
Description copied from class: WeightedPageRank
Calls WeightedPageRank.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 class WeightedPageRank
Parameters:
stoppingCriterion - the stopping criterion to be used.
Throws:
IOException - if an exception occurs during computation.

normDelta

public double normDelta()
Description copied from class: WeightedPageRank
Returns a norm of the difference with the previous step rank vector. The kind of norm is usually established in the constructor.

Overrides:
normDelta in class WeightedPageRank
Returns:
a norm of the difference with the previous step rank vector.

clear

public void clear()
Description copied from class: WeightedPageRank
Clears all data. After calling this method, data about the last PageRank computations are cleared, and you should call again WeightedPageRank.init() before computing PageRank again.

Overrides:
clear in class WeightedPageRank

main

public static void main(String[] arg)
                 throws IOException,
                        JSAPException,
                        org.apache.commons.configuration.ConfigurationException,
                        ClassNotFoundException
Throws:
IOException
JSAPException
org.apache.commons.configuration.ConfigurationException
ClassNotFoundException