Skip to content

Divisive community algorithms - #5830

Merged
dschult merged 8 commits into
networkx:mainfrom
MridulS:divisive_comm
Jan 19, 2024
Merged

dschult merged 8 commits into
networkx:mainfrom
MridulS:divisive_comm

Conversation

@MridulS

@MridulS MridulS commented Jun 29, 2022

Copy link
Copy Markdown
Member

This PR brings in the algorithms implemented in #764, cleaned up a bit.

@jarrodmillman

Copy link
Copy Markdown
Member

It would be great to get this algorithm in!

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I'm not sure how effective it will be because it is slow -- but the doc_string warns that it is slow. So I think that is up to the user to determine.

My comments are minor things. It will also need "black". And it doesn't test the normalized and weight optional arguments. (They are tested in the tests for betweenness_centrality, so maybe that's OK.) I also wondered if the normalized parameter makes any difference because the maximum is all that is used, and the max shouldn't depend on normalization... but that's probably OK too.

@dschult

dschult commented Dec 11, 2022

Copy link
Copy Markdown
Member

I've been looking at this due to Jarrod's comment above that we try to get it in soon.
The main issue I see is that the code tries to split G into a specified number of components. But the underlying functions to compute the betweenness raise an exception if G is not connected. So, we need to compute the betweenness values on each component separately.

This overlaps slightly with the issue of whether the values should be normalized or not. Since we are going to have to compute the betweenness values separately for each component, and then compare them to find the highest betweenness edge. If they are normalized based on the component, they will have different normalization factors. So, I'm thinking that we should not use normalized scores. [Even in the case of edge rankings that don't require connected graphs, normalizing should not affect which edge is maximal. So there is no reason the user should need to specify whether we normalize the ranks or not. And that also reduces the input arguments by one -- Yay! :}

I'm close to making these changes to this PR, but if you have an idea or perspective that would help please let me know. Also, I'm thinking I can push directly to the PR because it is fixing the test errors and this is a rewrite of a previous PR. If anyone would prefer that I make a PR to the branch that is this PR, let me know.

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks ready to merge.
The tracking of partitions was implemented a year ago, but I never marked this as ready to review.

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @MridulS ! Just a few minor comments - I'll let someone else take one last look and push the button!

@rossbar

rossbar commented Jan 17, 2024

Copy link
Copy Markdown
Contributor

Just a quick ping here @MridulS - if there are no objections to making weight keyword-only, then we can quickly add that and merge. Otherwise, we can just merge!

@dschult dschult left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me!
:)
Thanks!

@dschult
dschult merged commit 3eecad3 into networkx:main Jan 19, 2024
@jarrodmillman jarrodmillman added this to the 3.3 milestone Jan 19, 2024
cvanelteren pushed a commit to cvanelteren/networkx that referenced this pull request Apr 22, 2024
* Divisive community algorithms

* Cleanup divisive community algos

* Change number_of_partitions to number of sets, doc_string tweaks,

examples, etc

* Rewrite so CF Btwness is called on each component separately

* importorskip numpy for edge_current_flow_betweenness

* fix isort trouble

* Apply suggestions from code review

Co-authored-by: Ross Barnowski <[email protected]>

* FEAT: adding a PoC of creating an internal cache

---------

Co-authored-by: Benjamin Edwards <[email protected]>
Co-authored-by: Dan Schult <[email protected]>
Co-authored-by: Ross Barnowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

5 participants