Class Centrality

Inheritance Relationships

Base Type

Derived Types

Class Documentation

class Centrality : public NetworKit::Algorithm

Abstract base class for centrality measures.

Subclassed by NetworKit::AlgebraicPageRank< Matrix >, NetworKit::AlgebraicSpanningEdgeCentrality< Matrix >, NetworKit::ApproxBetweenness, NetworKit::ApproxCloseness, NetworKit::ApproxElectricalCloseness, NetworKit::Betweenness, NetworKit::Closeness, NetworKit::CoreDecomposition, NetworKit::DegreeCentrality, NetworKit::DynApproxBetweenness, NetworKit::DynBetweenness, NetworKit::DynKatzCentrality, NetworKit::EigenvectorCentrality, NetworKit::EstimateBetweenness, NetworKit::ForestCentrality, NetworKit::HarmonicCloseness, NetworKit::KPathCentrality, NetworKit::KatzCentrality, NetworKit::LaplacianCentrality, NetworKit::LocalClusteringCoefficient, NetworKit::LocalPartitionCoverage, NetworKit::LocalSquareClusteringCoefficient, NetworKit::PageRank, NetworKit::Sfigality, NetworKit::SpanningEdgeCentrality

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.

  • 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.


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).


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().


A vector of pairs.

virtual double score(node v)

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


v – A node.


The betweenness score of node v.

virtual double maximum()

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


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.


centrality index

Protected Attributes

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