# [GRASS-user] v.net.centrality closeness

Moritz Lennert mlennert at club.worldonline.be
Thu Sep 11 06:44:19 PDT 2014

```On 10/09/14 16:31, Will Fields wrote:
> I'm using v.net.centrality to do some calculations, and I had a question
> about how closeness centrality is calculated by the module:
> Is the value for closeness centrality actually "farness" (the sum of the
> distance from a site in a network to all other sites in the network)?
> v.net.centrality is returning large values for closeness in a data
> set rather than a decimal between 0 and 1.  I tried to look through the
> C code for the module, but I wasn't able to make sense of it.

I think you are right. In its current form, it seems to be more of a
measure of "farness".

By inverting the "closeness" variable with a simple

1 / closeness

I get a result that seems more adequate.

But I also don't really understand the calculations in the code.
Notably, if farness of a node is (according to the Wikipedia article
referenced in the man page) "the sum of its distances to all other
nodes", shouldn't it be the sum of the distances of the node to all
other nodes, i.e. you should be able to calculate farness using
v.net.allpair and then summing the distances by from_node ?

When I use v.net.centrality on a network combining streets_wake and
schools_wake from the NC dataset and I calculate the "closeness" (aka
farness), I get this for the nodes with the highest values:

cat |     dist
-----+--------------
39 | 39769.319852
128 | 39316.769189
159 | 38730.565742
38 | 34311.673453
59 | 33649.126805
112 | 33406.022609
131 | 33080.405319
140 | 33062.412818
33 | 32580.971836
135 | 32183.519299
77 | 32059.527469
158 | 32039.010031
129 | 31501.214954
103 | 31327.647516
42 |  31283.00064

But when I calculate all distances with v.net.allpairs and the sum the
distances by from_cat, I get

from_cat |    dist
----------+-------------
39 | 6254233.946
128 | 6175455.627
159 | 6080808.494
140 |  5498739.16
33 | 5403162.189
38 | 5336049.601
158 | 5322613.245
112 | 5241168.562
131 | 5211368.296
59 | 5201325.561
103 |  5182372.74
156 | 5171904.939
157 | 5116144.746
143 | 5065893.211
77 | 5047493.908

i.e. both the values _and_ the order of nodes are different.

Maybe you should file two bugs against v.net.centrality:

1) make closeness the real closeness, i.e. the inverse of farness

2) improve the documentation of the module by explaining the exact
calculations of each variable, instead of just referencing a Wikipedia
article

Moritz

```