Skip to content

Louvain algorithm #3

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

Closed
wants to merge 4 commits into from
Closed

Conversation

jalving
Copy link

@jalving jalving commented Jan 30, 2019

Here is a simple implementation of the Louvain fast-unfolding algorithm I whipped up. It has been giving valid communities for my problems.

The algorithm could use some speed-up enhancements. Notably, I'm using the LightGraphs.modularity function to calculate modularity change in my loop as opposed to calculating the change directly.

Please feel free to comment or make changes.

adding louvain fast unfolding
export the function
adding test and Require entry
@simonschoelly
Copy link
Member

I think your pr kind of went unnoticed, as there is not much activity on this package at the moment. I will try to have a look at your pr soon.

@jalving
Copy link
Author

jalving commented Mar 2, 2019

No rush, I've been using community detection methods in my research and figured this is the best place to share the work.

@VPetukhov
Copy link

Hi @simonschoelly , do you by chance have any updates on this?

@storopoli
Copy link
Contributor

I did some benchmarking and the algorithm is performing very well

using BenchmarkTools
G = erdos_renyi(100, 0.1)

@benchmark community_detection_louvain(G)
@benchmark community_detection_bethe(G)

Benchmark for Bethe

BenchmarkTools.Trial: 
  memory estimate:  523.06 KiB
  allocs estimate:  266
  --------------
  minimum time:     1.485 ms (0.00% GC)
  median time:      1.766 ms (0.00% GC)
  mean time:        1.943 ms (3.15% GC)
  maximum time:     46.315 ms (0.00% GC)
  --------------
  samples:          2572
  evals/sample:     1

Benchmark for Louvain

BenchmarkTools.Trial: 
  memory estimate:  181.54 MiB
  allocs estimate:  77601
  --------------
  minimum time:     337.115 ms (7.82% GC)
  median time:      352.989 ms (7.50% GC)
  mean time:        355.509 ms (7.61% GC)
  maximum time:     382.444 ms (5.86% GC)
  --------------
  samples:          15
  evals/sample:     1

I think it's time to do a pull request and make it to the codebase


function louvain_make_pass(graph::AbstractGraph,communities::Vector{Int},tol::Float64)
comm_list = copy(communities)
current_modularity = modularity(graph,comm_list)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible to use a memoing function or to have the current_modularity cached? I think this is the major bottleneck in performance. Did you profiled the code to inspect what are the major bottlenecks?

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for taking a look at the algorithm. I never did any profiling but it shouldn't be too bad to check the bottlenecks. I'll take a look at improving the benchmark. Maybe we can merge once we're happy with the performance?

Copy link
Contributor

Choose a reason for hiding this comment

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

@gdalle
Copy link
Member

gdalle commented Nov 15, 2023

Closed in favor of #4

@gdalle gdalle closed this Nov 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants