| Line | Hits | Source |
|---|---|---|
| 1 | /* | |
| 2 | * Copyright (c) 2003, the JUNG Project and the Regents of the University | |
| 3 | * of California | |
| 4 | * All rights reserved. | |
| 5 | * | |
| 6 | * This software is open-source under the BSD license; see either | |
| 7 | * "license.txt" or | |
| 8 | * http://jung.sourceforge.net/license.txt for a description. | |
| 9 | */ | |
| 10 | package edu.uci.ics.jung.algorithms.importance; | |
| 11 | ||
| 12 | ||
| 13 | /** | |
| 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. | |
| 16 | * @author Scott White | |
| 17 | */ | |
| 18 | public abstract class Ranking implements Comparable { | |
| 19 | /** | |
| 20 | * The original (0-indexed) position of the instance being ranked | |
| 21 | */ | |
| 22 | public int originalPos; | |
| 23 | /** | |
| 24 | * The actual rank score (normally between 0 and 1) | |
| 25 | */ | |
| 26 | public double rankScore; | |
| 27 | ||
| 28 | /** | |
| 29 | * Constructor which allows values to be set on construction | |
| 30 | * @param originalPos The original (0-indexed) position of the instance being ranked | |
| 31 | * @param rankScore The actual rank score (normally between 0 and 1) | |
| 32 | */ | |
| 33 | 20170 | public Ranking(int originalPos, double rankScore) { |
| 34 | 20170 | this.originalPos = originalPos; |
| 35 | 20170 | this.rankScore = rankScore; |
| 36 | 20170 | } |
| 37 | ||
| 38 | /** | |
| 39 | * Compares two ranking based on the rank score. | |
| 40 | * @param o The other ranking | |
| 41 | * @return -1 if the other ranking is higher, 0 if they are equal, and 1 if this ranking is higher | |
| 42 | */ | |
| 43 | public int compareTo(Object o) { | |
| 44 | ||
| 45 | 20343 | Ranking otherRanking = (Ranking) o; |
| 46 | 20343 | return Double.compare(otherRanking.rankScore,rankScore); |
| 47 | } | |
| 48 | ||
| 49 | /** | |
| 50 | * Returns the rank score as a string. | |
| 51 | * @return the stringified rank score | |
| 52 | */ | |
| 53 | public String toString() { | |
| 54 | 0 | return String.valueOf(rankScore); |
| 55 | } | |
| 56 | } |
|
this report was generated by version 1.0.5 of jcoverage. |
copyright © 2003, jcoverage ltd. all rights reserved. |