# Class Centrality¶

## Class Documentation¶

class Centrality : public NetworKit::Algorithm

Abstract base class for centrality measures.

Public Functions

Centrality(const Graph &G, bool normalized = false, bool computeEdgeCentrality = false)

Constructs the Centrality class for the given Graph G. If the centrality scores should be normalized, then set normalized to `true`.

Parameters:
• G – The graph.

• normalized – If set to `true` the scores are normalized in the interval [0,1].

• computeEdgeCentrality – If true, compute also edge centralities (for algorithms where this is applicable)

virtual void run() override = 0

Computes centrality scores on the graph passed in constructor.

virtual const std::vector<double> &scores() const

Get a vector containing the centrality score for each node in the graph.

Returns:

The centrality scores calculated by run().

virtual std::vector<double> edgeScores()

Get a vector containing the edge centrality score for each edge in the graph (where applicable).

Returns:

The edge betweenness scores calculated by run().

virtual std::vector<std::pair<node, double>> ranking()

Get a vector of pairs sorted into descending order. Each pair contains a node and the corresponding score calculated by run().

Returns:

A vector of pairs.

virtual double score(node v)

Get the centrality score of node v calculated by run().

Parameters:

v – A node.

Returns:

The betweenness score of node v.

virtual double maximum()

Get the theoretical maximum of centrality score in the given graph.

Returns:

The maximum centrality score.

virtual double centralization()

Compute the centralization of a network with respect to some centrality measure.

The centralization of any network is a measure of how central its most central node is in relation to how central all the other nodes are. Centralization measures then (a) calculate the sum in differences in centrality between the most central node in a network and all other nodes; and (b) divide this quantity by the theoretically largest such sum of differences in any network of the same size.

Returns:

centrality index

Protected Attributes

const Graph &G
std::vector<double> scoreData
std::vector<double> edgeScoreData
bool normalized
bool computeEdgeCentrality