Class AbstractRanker<V,E>
java.lang.Object
edu.uci.ics.jung.algorithms.util.IterativeProcess
edu.uci.ics.jung.algorithms.importance.AbstractRanker<V,E>
- All Implemented Interfaces:
IterativeContext
- Direct Known Subclasses:
BetweennessCentrality, RelativeAuthorityRanker, WeightedNIPaths
Abstract class for algorithms that rank nodes or edges by some "importance" metric. Provides a common set of
services such as:
- storing rank scores
- getters and setters for rank scores
- computing default edge weights
- normalizing default or user-provided edge transition weights
- normalizing rank scores
- automatic cleanup of decorations
- creation of Ranking list
- print rankings in sorted order by rank
By default, all rank scores are removed from the vertices (or edges) being ranked.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprivate booleanprivate booleanprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidprotected voidPerform eventual clean-up operations (must be implement by subclass when needed).doubledoublegetEdgeRankScore(E e, Object key) getEdgeRankScores(Object key) protected doublegetEdgeWeight(E e) getGraph()Retrieves the list of ranking instances in descending sorted order by rank score If the algorithm is ranking edges, the instances will be of typeEdgeRanking, otherwise if the algorithm is ranking nodes the instances will be of typeNodeRankingabstract ObjectThe user datum key used to store the rank score.getRankScores(int topKRankings) Return a list of the top k rank scores.protected intdoubleGiven a node, returns the corresponding rank score.doublegetVertexRankScore(V v, Object key) protected Collection<V> protected voidinitialize(Graph<V, E> graph, boolean isNodeRanker, boolean isEdgeRanker) booleanbooleanprotected voidprotected voidprotected voidonFinalize(Object e) voidprintRankings(boolean verbose, boolean printScore) Print the rankings to standard out in descending order of rank scoreprotected voidprotected voidremoveEdgeRankScore(E e, Object key) protected voidprotected voidremoveVertexRankScore(V v, Object key) voidreset()protected voidsetEdgeRankScore(E e, double rankValue) protected voidsetEdgeRankScore(E e, double rankValue, Object key) protected voidsetEdgeWeight(E e, double weight) voidsetEdgeWeights(Map<E, Number> edgeWeights) voidsetNormalizeRankings(boolean normalizeRankings) Allows the user to specify whether or not s/he wants the rankings to be normalized.voidsetRemoveRankScoresOnFinalize(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.protected voidsetVertexRankScore(V v, double rankValue) protected voidsetVertexRankScore(V v, double rankValue, Object key) Methods inherited from class IterativeProcess
done, evaluate, getDesiredPrecision, getIterations, getMaximumIterations, getPrecision, hasConverged, initializeIterations, relativePrecision, setDesiredPrecision, setMaximumIterations, setPrecision, step
-
Field Details
-
mGraph
-
mRankings
-
mRemoveRankScoresOnFinalize
private boolean mRemoveRankScoresOnFinalize -
mRankNodes
private boolean mRankNodes -
mRankEdges
private boolean mRankEdges -
mNormalizeRankings
private boolean mNormalizeRankings -
vertexRankScores
-
edgeRankScores
-
edgeWeights
-
-
Constructor Details
-
AbstractRanker
public AbstractRanker()
-
-
Method Details
-
initialize
-
getVertexRankScores
-
getEdgeRankScores
-
getVertexRankScores
-
getEdgeRankScores
-
getVertices
-
getVertexCount
protected int getVertexCount() -
getGraph
-
reset
public void reset()- Overrides:
resetin classIterativeProcess
-
isRankingNodes
public boolean isRankingNodes()- Returns:
trueif this ranker ranks nodes, andfalseotherwise.
-
isRankingEdges
public boolean isRankingEdges()- Returns:
trueif this ranker ranks edges, andfalseotherwise.
-
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-trueif the rank scores are to be removed,falseotherwise
-
onFinalize
-
getRankScoreKey
The user datum key used to store the rank score.- Returns:
- the key
-
finalizeIterations
protected void finalizeIterations()Description copied from class:IterativeProcessPerform eventual clean-up operations (must be implement by subclass when needed).- Overrides:
finalizeIterationsin classIterativeProcess
-
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 typeEdgeRanking, otherwise if the algorithm is ranking nodes the instances will be of typeNodeRanking- Returns:
- the list of rankings
-
getRankScores
-
getVertexRankScore
Given a 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 ifsetRemoveRankScoresOnFinalize(false)was called prior toevaluate().- Parameters:
v- the node whose rank score is to be returned.- Returns:
- the rank score value
-
getVertexRankScore
-
getEdgeRankScore
-
getEdgeRankScore
-
setVertexRankScore
-
setEdgeRankScore
-
setVertexRankScore
-
setEdgeRankScore
-
removeVertexRankScore
-
removeEdgeRankScore
-
removeVertexRankScore
-
removeEdgeRankScore
-
getEdgeWeight
-
setEdgeWeight
-
setEdgeWeights
-
getEdgeWeights
-
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- iftrue, include information about the actual rank order as well as the original position of the vertex before it was rankedprintScore- iftrue, 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-trueiff the ranking are to be normalized
-