recently, I have been comparing implementations of various centralities in Python graph libraries and it has been surprisingly difficult to obtain identical results.
I particular, I would like to obtain similar results for closeness centrality for directed graphs, where some nodes may have zero in or out-degrees.
Depending on the definition, one can decide to have undefined (nan) or zero centralities for such nodes.
However, igraph currently replaces the distance of these nodes by the number of vertices in the graph. While this is one choice among others, it does not necessarily fit the user’s needs.
How difficult would it be to propose a user-defined choice for this length? (e.g. between nan, 0, and using the number of vertices).
I have given a quick look at the implementation but I must say that, for somebody discovering igraph’s internals for the first time, the algorithm is not very easy to read…
In principle, I do not think the proposed change is difficult to implement and I may be able to propose an implementation if somebody can give me a brief overview of the algorithm but I’m afraid I do not have time to try to figure it out on my own.
In addition to this, a similar question would be whether it is possible to implement the harmonic definition of the closeness centrality:
EDIT: to contextualize, I think this feature would provide several benefits,
- more versatile
- provide ways to get similar results between graph-tool, igraph, and networkx in python
- eventually remove the need for the runtimewarning for “disconnected graph” (they are generally not) if the closeness returned for nodes with zero in/out-degree is NaN by default (could be done in a few releases if deemed desirable); a warning can be overlooked while a NaN tends to stand out