1 /*
2 * Created on Jul 6, 2007
3 *
4 * Copyright (c) 2007, The JUNG Authors
5 *
6 * All rights reserved.
7 *
8 * This software is open-source under the BSD license; see either
9 * "license.txt" or
10 * https://github.com/jrtom/jung/blob/master/LICENSE for a description.
11 */
12 package edu.uci.ics.jung.algorithms.scoring;
13
14 import edu.uci.ics.jung.graph.Hypergraph;
15
16 /**
17 * Assigns a score to each vertex equal to its degree.
18 *
19 * @param <V> the vertex type
20 */
21 public class DegreeScorer<V> implements VertexScorer<V,Integer>
22 {
23 /**
24 * The graph for which scores are to be generated.
25 */
26 protected Hypergraph<V,?> graph;
27
28 /**
29 * Creates an instance for the specified graph.
30 * @param graph the input graph
31 */
32 public DegreeScorer(Hypergraph<V,?> graph)
33 {
34 this.graph = graph;
35 }
36
37 /**
38 * Returns the degree of the vertex.
39 * @return the degree of the vertex
40 */
41 public Integer getVertexScore(V v)
42 {
43 return graph.degree(v);
44 }
45 }