Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

[BUG] Wrong values of Betweenness centrality #1405

@sergio-gomez

Description

@sergio-gomez

Description of bug
Betweenness centrality reports meaningless values when the network is a bit large

How to reproduce
julia> G = SimpleGraphs.grid([50, 50])
julia> btw = betweenness_centrality(G, normalize=false, endpoints=false)
julia> maximum(btw)
6.360647079664976e10

Expected behavior
I've calculated the maximum betweenness with a different software (Radatools), and the result should be:
90107.6985

Actual behavior
The maximum betweenness cannot be larger than the number of pairs
julia> pairs = div((nv(G)-1) * (nv(G)-2), 2)
3121251

In fact, there are many nodes with betweenness reported larger than the number of pairs:
julia> btw_large = btw[btw .> pairs]
julia> length(btw_large)
2264

As a reference, the network (a 50x50 grid) has 2500 nodes.

Code demonstrating bug
See above.

Version information

  • output from versioninfo() surrounded by backticks (``)
    Julia Version 1.4.0
    Commit b8e9a9ecc6 (2020-03-21 16:36 UTC)
    Platform Info:
    OS: Windows (x86_64-w64-mingw32)
    CPU: Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
    WORD_SIZE: 64
    LIBM: libopenlibm
    LLVM: libLLVM-8.0.1 (ORCJIT, skylake)

  • output from ] status LightGraphs surrounded by backticks (``)
    [093fc24a] LightGraphs v1.3.1

Additional context
Betweenness is calculated correctly for smaller networks (in particular, smaller grids). For example, a grid 21x21 has maximum betweenness
6369.052660310278
which I've replicated with Radatools. There is a factor 2 between Radatools and LightGraphs values, which is not relevant, because Radatools considers as different the pairs (i, j) and (j, i).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconfirmed bug producing incorrect results

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions