question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Betweenness Centrality calculated for entire graph, not calling collection

See original GitHub issue

Issue type

Bug report

Environment info

  • Cytoscape.js version : 3.14.0
  • Browser/Node.js & version : 13.10.1

Current (buggy) behaviour

I have a completely connected graph. I select a subgraph of this that contains all nodes but different edges (e.g. cy.elements('nodes, edges[weight < 50]'). When I run the betweennessCentrality function (alias bc) on this subgraph collection, it calculates betweenness centrality for the whole graph, not respecting the collection.

Desired behaviour

I was expecting a similar outcome to if I were to run it on a clone of the graph without the elements outside the subgraph. I.e.

cy = cytoscape({ elements: cy.elements('node, edge[weight > 50]').jsons() });
let bc = cy.elements().bc();
cy.nodes().map(bc.betweenness);

Minimum steps to reproduce

Go to whatever example on the main page (I use grid layout) and find the betweenness centralities of a collection without any edges whatsoever (theoretically it should give you all zeros).

let bc = cy.nodes().bc();
cy.nodes().map(bc.betweenness);

It doesn’t give you all zeros and acts as if we are considering the whole graph, unlike what the documentation suggests (“Considering only the elements in the calling collection, calculate the betweenness centrality of the nodes.”).

Thanks.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
somedmguycommented, Mar 13, 2020

I would expect the source of the problem is how the algorithm makes use of calls to outgoers() openNeighborhood() and edgesTo() multiple times. None of these is bounded by the source collection, so they all will reach out to the entire graph.

0reactions
maxkfranzcommented, Apr 6, 2020

I can add @somedmguy’s suggested change, but I need someone to provide sample data for at least one subgraph test case.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Betweenness Centrality - an overview | ScienceDirect Topics
The betweenness centrality captures how much a given node (hereby denoted u) is in-between others. This metric is measured with the number of...
Read more >
Betweenness Centrality - Neo4j Graph Data Science
The algorithm calculates shortest paths between all pairs of nodes in a graph. Each node receives a score, based on the number of...
Read more >
Chapter 10: Centrality and power
The UCINET Network>Centrality>Eigenvector routine calculates individual actor centrality, and graph centralization using weights on the first eigenvector. A ...
Read more >
Centrality Tutorial - NetworKit
It is calculated as inverse of the average of the shortest path length from the node to every other node in the network....
Read more >
12 Centrality | Methods for Network Analysis
Betweenness centrality captures which nodes are important in the flow of the network. It makes use of the shortest paths in the network....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found