View Javadoc
1   /*
2    * Created on Jul 12, 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 com.google.common.base.Function;
15  
16  import edu.uci.ics.jung.algorithms.shortestpath.Distance;
17  import edu.uci.ics.jung.graph.Hypergraph;
18  
19  /**
20   * Assigns scores to each vertex based on the mean distance to each other vertex.
21   * 
22   * @author Joshua O'Madadhain
23   */
24  public class ClosenessCentrality<V,E> extends DistanceCentralityScorer<V,E>
25  {
26  
27      /**
28       * Creates an instance using the specified vertex/vertex distance metric.
29       * @param graph the input
30       * @param distance the vertex/vertex distance metric.
31       */
32      public ClosenessCentrality(Hypergraph<V,E> graph, Distance<V> distance)
33      {
34          super(graph, distance, true);
35      }
36  
37      /**
38       * Creates an instance which measures distance using the specified edge weights.
39       * @param graph the input graph
40       * @param edge_weights the edge weights to be used to determine vertex/vertex distances
41       */
42      public ClosenessCentrality(Hypergraph<V,E> graph, Function<E, ? extends Number> edge_weights)
43      {
44          super(graph, edge_weights, true);
45      }
46  
47      /**
48       * Creates an instance which measures distance on the graph without edge weights.
49       * @param graph the graph whose vertices' centrality scores will be calculated
50       */
51      public ClosenessCentrality(Hypergraph<V,E> graph)
52      {
53          super(graph, true);
54      }
55  }