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

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 java.util.Iterator;
13  
14 import edu.uci.ics.jung.algorithms.shortestpath.DijkstraDistance;
15 import edu.uci.ics.jung.graph.Graph;
16 import edu.uci.ics.jung.graph.Vertex;
17  
18  
19 /**
20  * A simple node importance ranker based on the total shortest path of the
21  * node. More central nodes in a connected component will have smaller
22  * overall shortest paths, and 'peripheral' nodes on the network will have
23  * larger overall shortest paths. Runing this ranker on a graph with more
24  * than one connected component will arbitarily mix nodes from both
25  * components. For this reason you should probably run this ranker on one
26  * component only (but that goes for all rankers).
27  *
28  * <p>
29  * A simple example of usage is:
30  * <pre>
31  * BaryCenter ranker = new BaryCenter(someGraph);
32  * ranker.evaluate();
33  * ranker.printRankings();
34  * </pre>
35  *
36  * @author Dan Bolser, Scott White
37  */
38 public class BaryCenter extends AbstractRanker {
39  
40     public final static String KEY =
41         "edu.uci.ics.jung.algorithms.importance.BaryCenter.RankScore";
42  
43     /**
44      * Constructor which initializes the algorithm
45      * @param g the graph whose nodes are to be analyzed
46      */
47     public BaryCenter(Graph g)
480    {
490        initialize(g, true, false);
500    }
51  
52     protected double evaluateIteration()
53     {
54         // Use this class to compute shortest path lengths.
550        DijkstraDistance p = new DijkstraDistance(getGraph());
56  
570        Iterator i = getVertices().iterator();
58  
590        while (i.hasNext())
60         {
610            Vertex u = (Vertex) i.next();
62  
630            double baryCenter = 0;
64  
650            Iterator j = p.getDistanceMap(u).values().iterator();
66  
670            while (j.hasNext())
68             {
690                baryCenter += ((Number) j.next()).doubleValue();
70             }
710            setRankScore(u, baryCenter);
72         }
730        return 0;
74     }
75  
76     public String getRankScoreKey()
77     {
780        return KEY;
79     }
80 }

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.