sbromberger / LightGraphs.jl

An optimized graphs package for the Julia programming language
Other
672 stars 185 forks source link

Centrality calculation results compared to Matlab R2018a and Mathematica 11.3 #930

Closed ghost closed 6 years ago

ghost commented 6 years ago

Attached a Jupyter Notebook with a simple graph. I compared especially the centrality calculations results of the same graph in Matlab R2018a and Mathematica 11.3. I am wondering about the differences. Can you explain? The sequence of values are less important I think. Basics-GraphTheory.zip

sbromberger commented 6 years ago

Can you point to a copy of the notebook online? I don't really make a habit of downloading zip files :)

ghost commented 6 years ago

The Notebook is directly downloadable here: https://drive.google.com/file/d/1olHAs6ZZY92o1gKRH96cnUz4K8TYYvPw/view?usp=sharing

sbromberger commented 6 years ago

So, for degree and betweenness, we normalize by default. Pass normalize=false to get the equivalent to matlab and mathematica.

sbromberger commented 6 years ago

PS: this is a really nice notebook. Would you mind working with @juliohm to see whether it belongs in https://github.com/JuliaGraphs/JuliaGraphsTutorials ?

ghost commented 6 years ago

YES, thank you. I have updated the notebook and the results are now fully in line with other software apart from Matlab and the closeness centrality. I assume there is a normalization problem as well. https://drive.google.com/file/d/1olHAs6ZZY92o1gKRH96cnUz4K8TYYvPw/view?usp=sharing

I suggest to improve the documentation. In (https://juliagraphs.github.io/LightGraphs.jl/latest/centrality.html) the option "normalize=true" is mentioned. This is misleading, because "normalize=true" is default. Please think about it.

sbromberger commented 6 years ago

I suggest to improve the documentation. In (https://juliagraphs.github.io/LightGraphs.jl/latest/centrality.html) the option "normalize=true" is mentioned. This is misleading, because "normalize=true" is default. Please think about it.

This is just a misunderstanding of how the documentation is formatted, I think. x = y in the Optional Arguments section just means that there's an optional argument x that takes a default value y. What follows is an explanation of the argument. For booleans, the opposite value's behavior is implied (that is, with normalize=true, it is better to explain what normalization will do, with the implication that normalize=false will NOT do that.)

sbromberger commented 6 years ago

also, I don't quite understand what you mean by

I assume there is a normalization problem as well.

The non-normalized values that LightGraphs produces are identical to Matlab (and, incidentally, with NetworkX, which is our correctness check for this stuff). The Mathematica results appear to be different in degree_centrality, but perhaps that's just a typo.

ghost commented 6 years ago

I think it would be useful to improve the documentation, so that it's easier to find the information that the default value is "true". That's all I would appreciate.

sbromberger commented 6 years ago

Can't argue with improved documentation! If you'd like to make a PR with your suggestions, we can certainly discuss.

sbromberger commented 6 years ago

Oh, also, I see what you mean about matlab closeness centrality - they're off by a multiple of 0.1. I wonder if they're doing some sort of normalization, but I don't use matlab so can't guess.

(In general, for large graphs, I've found I don't really care about the absolute centrality values; the ranking is more important to me.)

ghost commented 6 years ago

If you look to the closeness centrality results you can find a factor 10 between LightGraphs & Mathematica compared with Matlab. As an example: for LightGraphs and Mathematica the first value is 0.277778. Matlab calculates 0.0277778. The diffence is a factor 10.

I have made only a quick check of Matlab help hystem. I couldn't find any useful information concerning normalization in graph calculation. But this might be my fault. Hence my assumption is that it can be a normalization problem on Matlab side.

No, there is no typo regarding the sequence of values for degree centrality. I simply made a copy and paste of the results. I will contact Wolfram to discuss the subject.

sbromberger commented 6 years ago

@JuergenKanz - We'll close this issue out but if you'd like to submit a PR with documentation improvements, I'd be grateful.