Writes the closeness centrality of each individual node to a text file. The file contains the centralities written in order of the node number.


filename: String
Name of the file to which the closeness centralities will be written


If n is the number of nodes in the network and l_{ij} is the length of the shortest path between nodes i and j, the closeness centrality of node i is defined as:

\frac{n-1}{ \sum_{j\neq i} l_{ij}}

The normalisation is such that the closeness centrality is always in the interval \left[ 0, 1 \right]. The distance between two nodes is defined as described in meanPathLength.

Example (python-conedy)

import conedy as co

N =

i = N.cycle(20, 1, co.node(), co.weightedEdge())

N.addEdge(i + 1, i + 7, co.weightedEdge(1.0))
N.addEdge(i + 7, i + 1, co.weightedEdge(2.0))
N.addEdge(i + 1, i +11, co.weightedEdge(3.0))
N.addEdge(i +11, i + 1, co.weightedEdge(4.0))


Example (conedy)

network N;

int i = N.cycle(20, 1, kuramoto());

N.addEdge(i+ 1, i+ 7, weightedEdge(1.0));
N.addEdge(i+ 7, i+ 1, weightedEdge(2.0));
N.addEdge(i+ 1, i+11, weightedEdge(3.0));
N.addEdge(i+11, i+ 1, weightedEdge(4.0));

N.closenessCentrality( "output/" );

Table Of Contents

Previous topic


Next topic