2 * Copyright (c) 2003, the JUNG Project and the Regents of the University
6 * This software is open-source under the BSD license; see either
8 * http://jung.sourceforge.net/license.txt for a description.
10 package edu.uci.ics.jung.algorithms.importance;
14 * Abstract data container for ranking objects. Stores common data relevant to both node and edge rankings, namely,
15 * the original position of the instance in the list and the actual ranking score.
18 public class Ranking<V> implements Comparable {
20 * The original (0-indexed) position of the instance being ranked
22 public int originalPos;
24 * The actual rank score (normally between 0 and 1)
26 public double rankScore;
29 * what is being ranked
34 * Constructor which allows values to be set on construction
35 * @param originalPos The original (0-indexed) position of the instance being ranked
36 * @param rankScore The actual rank score (normally between 0 and 1)
38 public Ranking(int originalPos, double rankScore, V ranked) {
39 this.originalPos = originalPos;
40 this.rankScore = rankScore;
45 * Compares two ranking based on the rank score.
46 * @param o The other ranking
47 * @return -1 if the other ranking is higher, 0 if they are equal, and 1 if this ranking is higher
49 public int compareTo(Object o) {
51 Ranking otherRanking = (Ranking) o;
52 return Double.compare(otherRanking.rankScore,rankScore);
56 * Returns the rank score as a string.
57 * @return the stringified rank score
60 public String toString() {
61 return String.valueOf(rankScore);
67 public V getRanked() {
72 * @param ranked the ranked to set
74 public void setRanked(V ranked) {