Coverage details for edu.uci.ics.jung.algorithms.importance.RelativeAuthorityRanker

LineHitsSource
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 import edu.uci.ics.jung.graph.Vertex;
13 import edu.uci.ics.jung.utils.MutableDouble;
14 import edu.uci.ics.jung.utils.UserData;
15  
16 import java.util.Set;
17 import java.util.Iterator;
18  
19 /**
20  * This class provides basic infrastructure for relative authority algorithms that compute the importance of nodes
21  * relative to one or more root nodes. The services provided are:
22  * <ul>
23  * <li>The set of root nodes (priors) is stored and maintained</li>
24  * <li>Getters and setters for the prior rank score are provided</li>
25  * </ul>
26  *
27  * @author Scott White
28  */
298public abstract class RelativeAuthorityRanker extends AbstractRanker {
30     private Set mPriors;
31     /**
32      * The default key used for the user datum key corresponding to prior rank scores.
33      */
34     public static final String PRIOR_KEY = "jung.algorithms.importance.RelativeAuthorityRanker.PriorRankScore";
35  
36     /**
37      * Cleans up all of the prior rank scores on finalize.
38      */
39     protected void finalizeIterations() {
408        super.finalizeIterations();
418        for (Iterator vIt = getVertices().iterator();vIt.hasNext();) {
4237            Vertex currentVertex = (Vertex) vIt.next();
4337            currentVertex.removeUserDatum(PRIOR_KEY);
44         }
45  
468    }
47  
48     /**
49      * Returns the user datum key for the prior rank score.
50      * @return the user datum key for the prior rank score
51      */
52     protected String getPriorRankScoreKey() {
530        return PRIOR_KEY;
54     }
55  
56     /**
57      * Retrieves the value of the prior rank score.
58      * @param v the root node (prior)
59      * @return the prior rank score
60      */
61     protected double getPriorRankScore(Vertex v) {
622588        return ((MutableDouble) v.getUserDatum(PRIOR_KEY)).doubleValue();
63  
64     }
65  
66     /**
67      * Allows the user to specify a value to set for the prior rank score
68      * @param v the root node (prior)
69      * @param value the score to set to
70      */
71     public void setPriorRankScore(Vertex v, double value) {
7246        MutableDouble doubleVal = (MutableDouble) v.getUserDatum(PRIOR_KEY);
7346        if (doubleVal == null) {
7430            doubleVal = new MutableDouble(value);
75         } else {
7616            doubleVal.setDoubleValue(value);
77         }
7846        v.setUserDatum(PRIOR_KEY,doubleVal,UserData.SHARED);
7946    }
80  
81     /**
82      * Retrieves the set of priors.
83      * @return the set of root nodes (priors)
84      */
8519    protected Set getPriors() { return mPriors; }
86  
87     /**
88      * Specifies which vertices are root nodes (priors).
89      * @param priors the root nodes
90      */
916    protected void setPriors(Set priors) { mPriors = priors; }
92 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.