edu.uci.ics.jung.algorithms.importance
Class AbstractRanker

java.lang.Object
  extended byedu.uci.ics.jung.algorithms.IterativeProcess
      extended byedu.uci.ics.jung.algorithms.importance.AbstractRanker
Direct Known Subclasses:
BetweennessCentrality, DegreeDistributionRanker, HITS, RandomWalkSTBetweenness, RelativeAuthorityRanker, WeightedNIPaths

public abstract class AbstractRanker
extends IterativeProcess

Abstract class for algorithms that rank nodes or edges by some "importance" metric. Provides a common set of services such as:

By default, all rank scores are removed from the vertices (or edges) being ranked.

Author:
Scott White

Field Summary
static java.lang.String DEFAULT_EDGE_WEIGHT_KEY
           
 
Constructor Summary
AbstractRanker()
           
 
Method Summary
 java.lang.String getEdgeWeightKeyName()
          the user datum key used to store the edge weight, if any
 java.util.List getRankings()
          Retrieves the list of ranking instances in descending sorted order by rank score If the algorithm is ranking edges, the instances will be of type EdgeRanking, otherwise if the algorithm is ranking nodes the instances will be of type NodeRanking
 double getRankScore(UserDataContainer v)
          Given an edge or node, returns the corresponding rank score.
abstract  java.lang.String getRankScoreKey()
          The user datum key used to store the rank score.
 cern.colt.list.DoubleArrayList getRankScores(int topKRankings)
          Return a list of the top k rank scores.
 boolean isRankingNodes()
          Indicates whether this ranker is ranking nodes or edges.
 void printRankings(boolean verbose, boolean printScore)
          Print the rankings to standard out in descending order of rank score
 void setNormalizeRankings(boolean normalizeRankings)
          Allows the user to specify whether or not s/he wants the rankings to be normalized.
 void setRemoveRankScoresOnFinalize(boolean removeRankScoresOnFinalize)
          Instructs the ranker whether or not it should remove the rank scores from the nodes (or edges) once the ranks have been computed.
 void setUserDefinedEdgeWeightKey(java.lang.String keyName)
          Allows the user to provide his own set of data instances as edge weights by giving the ranker the UserDatum key where those instances can be found.
 
Methods inherited from class edu.uci.ics.jung.algorithms.IterativeProcess
evaluate, getDesiredPrecision, getIterations, getMaximumIterations, getPrecision, hasConverged, relativePrecision, setDesiredPrecision, setMaximumIterations
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EDGE_WEIGHT_KEY

public static final java.lang.String DEFAULT_EDGE_WEIGHT_KEY
See Also:
Constant Field Values
Constructor Detail

AbstractRanker

public AbstractRanker()
Method Detail

isRankingNodes

public boolean isRankingNodes()
Indicates whether this ranker is ranking nodes or edges.

Returns:
true if the ranker it ranking nodes, false if it's ranking edges

setRemoveRankScoresOnFinalize

public void setRemoveRankScoresOnFinalize(boolean removeRankScoresOnFinalize)
Instructs the ranker whether or not it should remove the rank scores from the nodes (or edges) once the ranks have been computed.

Parameters:
removeRankScoresOnFinalize - true if the rank scores are to be removed, false otherwise

getRankings

public java.util.List getRankings()
Retrieves the list of ranking instances in descending sorted order by rank score If the algorithm is ranking edges, the instances will be of type EdgeRanking, otherwise if the algorithm is ranking nodes the instances will be of type NodeRanking

Returns:
the list of rankings

getRankScores

public cern.colt.list.DoubleArrayList getRankScores(int topKRankings)
Return a list of the top k rank scores.

Parameters:
topKRankings - the value of k to use
Returns:
list of rank scores

getRankScoreKey

public abstract java.lang.String getRankScoreKey()
The user datum key used to store the rank score.

Returns:
the key

getRankScore

public double getRankScore(UserDataContainer v)
Given an edge or node, returns the corresponding rank score. This is a default implementation of getRankScore which assumes the decorations are of type MutableDouble. This method only returns legal values if setRemoveRankScoresOnFinalize(false) was called prior to evaluate();

Returns:
the rank score value

getEdgeWeightKeyName

public java.lang.String getEdgeWeightKeyName()
the user datum key used to store the edge weight, if any

Returns:
the key

printRankings

public void printRankings(boolean verbose,
                          boolean printScore)
Print the rankings to standard out in descending order of rank score

Parameters:
verbose - if true, include information about the actual rank order as well as the original position of the vertex before it was ranked
printScore - if true, include the actual value of the rank score

setNormalizeRankings

public void setNormalizeRankings(boolean normalizeRankings)
Allows the user to specify whether or not s/he wants the rankings to be normalized. In some cases, this will have no effect since the algorithm doesn't allow normalization as an option

Parameters:
normalizeRankings -

setUserDefinedEdgeWeightKey

public void setUserDefinedEdgeWeightKey(java.lang.String keyName)
Allows the user to provide his own set of data instances as edge weights by giving the ranker the UserDatum key where those instances can be found.

Parameters:
keyName - the name of the UserDatum key where the data instance representing an edge weight can be found