org.neo4j.graphalgo.impl.centrality
Class ClosenessCentrality<ShortestPathCostType>

java.lang.Object
  extended by org.neo4j.graphalgo.impl.centrality.ShortestPathBasedCentrality<ShortestPathCostType,ShortestPathCostType>
      extended by org.neo4j.graphalgo.impl.centrality.ClosenessCentrality<ShortestPathCostType>
Type Parameters:
ShortestPathCostType - The datatype used by the underlying SingleSourceShortestPath algorithm, i.e. the type the edge weights are represented by.

public class ClosenessCentrality<ShortestPathCostType>
extends ShortestPathBasedCentrality<ShortestPathCostType,ShortestPathCostType>

Implementation of closeness centrality, which can be seen as the "average" distance from every node to all other nodes.

Author:
Patrik Larsson

Field Summary
 
Fields inherited from class org.neo4j.graphalgo.impl.centrality.ShortestPathBasedCentrality
centralities, centralityAccumulator, doneCalculation, nodeSet, singleSourceShortestPath, zeroValue
 
Constructor Summary
ClosenessCentrality(SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath, CostAccumulator<ShortestPathCostType> centralityAccumulator, ShortestPathCostType zeroValue, Set<Node> nodeSet, CostDivider<ShortestPathCostType> centralityDivider)
          Default constructor.
 
Method Summary
 ShortestPathCostType getCentrality(Node node)
          This can be used to retrieve the result for every node.
 void processShortestPaths(Node node, SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath)
          This is the abstract method all centrality algorithms based on this class need to implement.
 
Methods inherited from class org.neo4j.graphalgo.impl.centrality.ShortestPathBasedCentrality
addCentralityToNode, calculate, reset, setCentralityForNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClosenessCentrality

public ClosenessCentrality(SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath,
                           CostAccumulator<ShortestPathCostType> centralityAccumulator,
                           ShortestPathCostType zeroValue,
                           Set<Node> nodeSet,
                           CostDivider<ShortestPathCostType> centralityDivider)
Default constructor.

Parameters:
singleSourceShortestPath - Underlying singleSourceShortestPath.
centralityAccumulator - Object capable of adding distances. Needed since an "average" will be computed.
zeroValue - Default value and starting value to the accumulator.
nodeSet - A set containing the nodes for which centrality values should be computed.
centralityDivider - An object capable of inverting a distance.
Method Detail

getCentrality

public ShortestPathCostType getCentrality(Node node)
Description copied from class: ShortestPathBasedCentrality
This can be used to retrieve the result for every node. Will return null if the node is not contained in the node set initially given.

Overrides:
getCentrality in class ShortestPathBasedCentrality<ShortestPathCostType,ShortestPathCostType>
Returns:

processShortestPaths

public void processShortestPaths(Node node,
                                 SingleSourceShortestPath<ShortestPathCostType> singleSourceShortestPath)
Description copied from class: ShortestPathBasedCentrality
This is the abstract method all centrality algorithms based on this class need to implement. It is called once for every node in the node set, along with a SingleSourceShortestPath starting in that node.

Specified by:
processShortestPaths in class ShortestPathBasedCentrality<ShortestPathCostType,ShortestPathCostType>


Copyright © 2002-2012 The Neo4j Graph Database Project. All Rights Reserved.