Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closeness Centrality Produces Wrong Results #2951

Open
ntt-ebehar opened this issue Oct 11, 2024 · 0 comments
Open

Closeness Centrality Produces Wrong Results #2951

ntt-ebehar opened this issue Oct 11, 2024 · 0 comments

Comments

@ntt-ebehar
Copy link

I believe the results of closeness centrality produces incorrect results in the undirected, weighted, not fully connected graph case.

I can verify results from my algorithm with the networkX library used in python.

The graph and python code:

G = nx.Graph()

# add nodes
G.add_node(0, name="a")
G.add_node(1, name="b")
G.add_node(2, name="c")
G.add_node(3, name="d")
G.add_node(4, name="e")
G.add_node(5, name="f")
G.add_node(6, name="g")
G.add_node(7, name="h")
G.add_node(8, name="i")
G.add_node(9, name="j")
G.add_node(10, name="k")

# add edge from node 0 to node 1
G.add_edge(0, 1, weight=1)
G.add_edge(0, 2, weight=1)
G.add_edge(0, 4, weight=5)
G.add_edge(1, 2, weight=4)
G.add_edge(1, 4, weight=1)
G.add_edge(1, 6, weight=1)
G.add_edge(2, 4, weight=1)
G.add_edge(2, 3, weight=3)
G.add_edge(4, 3, weight=2)
G.add_edge(4, 6, weight=2)
G.add_edge(3, 6, weight=5)
G.add_edge(3, 5, weight=1)
G.add_edge(6, 5, weight=1)
G.add_edge(7, 8, weight=3)
G.add_edge(8, 9, weight=3)

print(nx.closeness_centrality(G, distance="weight", wf_improved=False))

Expected Behavior

Closeness Centrality produces these values:
{0: 0.46153846153846156, 1: 0.6, 2: 0.42857142857142855, 3: 0.4, 4: 0.5454545454545454, 5: 0.42857142857142855, 6: 0.5454545454545454, 7: 0.2222222222222222, 8: 0.3333333333333333, 9: 0.2222222222222222, 10: 0.0}

Current Behavior

Gephi produces these values: {0: 0.6, 1: 0.75, 2: 0.75, 3: 0.75, 4: 0.857143, 5: 0.545455, 6: 0.75, 7: 0.6667, 8: 1.0, 9: 0.6667, 10: 0.0}

Possible Solution

Revisit the algorithm and examine what it is doing in the case where the graph is undirected, weighted, and not fully connected.

Steps to Reproduce

Attached is the file of the graph thats producing perceived incorrect results.ClosenessGraph.csv

  1. Create the above graph in the Gephi application
  2. Run Network Diameter with: Directed selected and Normalize Centralities in [0,1] set to true
  3. Use Data Laboratory to inspect closeness column

Screenshot 2024-10-11 135703
Screenshot 2024-10-11 135636

Context

Trying to verify results for the algorithms that I am building for a client project. This feature works in the other case combinations of: directed, undirected, weighted, unweighted, fully connected, not fully connected but fails in the above scenario.

Your Environment

I am using Gephi application on Windows 11

  • Version used: Gephi 0.10.1
  • Operating System: Windows 11.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant