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

java.lang.Object
  extended by edu.uci.ics.jung.algorithms.IterativeProcess
      extended by edu.uci.ics.jung.algorithms.importance.AbstractRanker
Direct Known Subclasses:
BaryCenter, BetweennessCentrality, BrandesBetweennessCentrality, DegreeDistributionRanker, HITS, NewmanBetweennessCentrality, 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 String DEFAULT_EDGE_WEIGHT_KEY
           
 
Constructor Summary
AbstractRanker()
           
 
Method Summary
protected  void assignDefaultEdgeTransitionWeights()
           
protected  void finalizeIterations()
          Perform eventual clean-up operations (must be implement by subclass when needed).
protected  double getEdgeWeight(Edge e)
           
 String getEdgeWeightKeyName()
          the user datum key used to store the edge weight, if any
protected  Graph getGraph()
           
 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(Element e)
          Given an edge or node, returns the corresponding rank score.
abstract  String getRankScoreKey()
          The user datum key used to store the rank score.
 DoubleArrayList getRankScores(int topKRankings)
          Return a list of the top k rank scores.
protected  Set getVertices()
           
protected  void initialize(Graph graph, boolean isNodeRanker, boolean isEdgeRanker)
           
 boolean isRankingEdges()
          Returns true if this ranker ranks edges, and false otherwise.
 boolean isRankingNodes()
          Returns true if this ranker ranks nodes, and false otherwise.
protected  void normalizeEdgeTransitionWeights()
           
protected  void normalizeRankings()
           
protected  void onFinalize(Element e)
           
 void printRankings(boolean verbose, boolean printScore)
          Print the rankings to standard out in descending order of rank score
protected  void reinitialize()
           
protected  void setEdgeWeight(Edge e, double weight)
           
 void setNormalizeRankings(boolean normalizeRankings)
          Allows the user to specify whether or not s/he wants the rankings to be normalized.
protected  void setRankScore(Element e, double rankValue)
           
 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(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, evaluateIteration, getDesiredPrecision, getIterations, getMaximumIterations, getPrecision, hasConverged, initializeIterations, relativePrecision, setDesiredPrecision, setMaximumIterations
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EDGE_WEIGHT_KEY

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

AbstractRanker

public AbstractRanker()
Method Detail

initialize

protected void initialize(Graph graph,
                          boolean isNodeRanker,
                          boolean isEdgeRanker)

getVertices

protected Set getVertices()

getGraph

protected Graph getGraph()

reinitialize

protected void reinitialize()
Overrides:
reinitialize in class IterativeProcess

isRankingNodes

public boolean isRankingNodes()
Returns true if this ranker ranks nodes, and false otherwise.


isRankingEdges

public boolean isRankingEdges()
Returns true if this ranker ranks edges, and false otherwise.


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

onFinalize

protected void onFinalize(Element e)

finalizeIterations

protected void finalizeIterations()
Description copied from class: IterativeProcess
Perform eventual clean-up operations (must be implement by subclass when needed).

Overrides:
finalizeIterations in class IterativeProcess

getRankings

public 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 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 String getRankScoreKey()
The user datum key used to store the rank score.

Returns:
the key

getRankScore

public double getRankScore(Element e)
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

setRankScore

protected void setRankScore(Element e,
                            double rankValue)

getEdgeWeight

protected double getEdgeWeight(Edge e)

getEdgeWeightKeyName

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

Returns:
the key

setEdgeWeight

protected void setEdgeWeight(Edge e,
                             double weight)

assignDefaultEdgeTransitionWeights

protected void assignDefaultEdgeTransitionWeights()

normalizeEdgeTransitionWeights

protected void normalizeEdgeTransitionWeights()

normalizeRankings

protected void normalizeRankings()

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(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