# Leiden algorithim implementation in Julia

**URL:** <https://discourse.julialang.org/t/leiden-algorithim-implementation-in-julia/55910>\
**Category:** Data\
**Tags:** question, networking, lightgraphs, clustering\
**Created:** [February 24, 2021, 4:02am UTC](https://discourse.julialang.org/t/leiden-algorithim-implementation-in-julia/55910 "2021-02-24T04:02:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![charperflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/charperflow/32/22252_2.png) [@charperflow](https://discourse.julialang.org/u/charperflow)\
**Post date:** [February 24, 2021, 4:02am UTC](https://discourse.julialang.org/t/leiden-algorithim-implementation-in-julia/55910/1 "2021-02-24T04:02:01Z")

</div>

I was wondering if anyone was aware of an implementation of the Leiden algorithm for Julia? It is a community detection algorithm which avoids the disconnected /poorly connected community problem associated with the louvain algorithm. I found this implementation here:

> **[GitHub - bicycle1885/Leiden.jl: A Julia implementation of the Leiden...](https://github.com/bicycle1885/Leiden.jl)**
>
> A Julia implementation of the Leiden algorithm for community detection. - GitHub - bicycle1885/Leiden.jl: A Julia implementation of the Leiden algorithm for community detection.

However the documentation is a bit sparse. After playing around with it I have encountered several issues. One is that it will randomly flag my input matrix as not symmetric at certain resolution parameters. I am also having a hard time telling if it is calculating values based off of modularity and how to set the null values.

I can dig through the source code in more detail, however, I am still relatively new at Julia and it seems to be taking advantage of a lot of tricks which I don’t know yet. I would appreciate it if anyone could point me in the direction of some more documentation for this implementation or perhaps a different implementation altogether!

---

<div class="post-metadata">

**Author:** ![Storopoli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/storopoli/32/209278_2.png) [@Storopoli](https://discourse.julialang.org/u/Storopoli)\
**Post date:** [March 4, 2021, 3:00pm UTC](https://discourse.julialang.org/t/leiden-algorithim-implementation-in-julia/55910/2 "2021-03-04T15:00:08Z")

</div>

The Julia [`CommunityDetection.jl`](https://github.com/JuliaGraphs/CommunityDetection.jl) from `JuliaGraphs` is somewhat abandoned. There is an [open PR](https://github.com/JuliaGraphs/CommunityDetection.jl/pull/3) from someone that I was helping to be merged to the repo that implemented Louvain.

Maybe we could add another PR to implement the Leiden and hope that the `CommunityDetection.jl` comes back to life.

---

<div class="post-metadata">

**Author:** ![charperflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/charperflow/32/22252_2.png) [@charperflow](https://discourse.julialang.org/u/charperflow)\
**Post date:** [March 4, 2021, 4:34pm UTC](https://discourse.julialang.org/t/leiden-algorithim-implementation-in-julia/55910/3 "2021-03-04T16:34:47Z")

</div>

I would definitely recommend adding the Leiden algorithm, if possible! It resolves issues the louvain algorithm has of forming weekly connected communities with each collapse step:

[https://www.nature.com/articles/s41598-019-41695-z](https://www.nature.com/articles/s41598-019-41695-z)

I have a version of the louvain algorithm that I made from scratch. However, I used it as a practice project when I was just getting to know Julia and is a complete mess. I’ve been working through Tom Kwong’s “design patterns and best practices with Julia” maybe when I finish it I can clean up my code and offer it up to the community 🙂

I’m currently in a bit of research pinch at the moment, so I’ll probably just use the python version of the Leiden algorithm, but if there’s nothing here by summer, it could be a fun summer project!

---

<div class="post-metadata">

**Author:** ![Storopoli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/storopoli/32/209278_2.png) [@Storopoli](https://discourse.julialang.org/u/Storopoli)\
**Post date:** [March 4, 2021, 4:42pm UTC](https://discourse.julialang.org/t/leiden-algorithim-implementation-in-julia/55910/4 "2021-03-04T16:42:04Z")

</div>

Sure I can help you out in your “summer” project. Call me up when you are available.

---

<div class="post-metadata">

**Author:** ![charperflow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/charperflow/32/22252_2.png) [@charperflow](https://discourse.julialang.org/u/charperflow)\
**Post date:** [March 4, 2021, 4:48pm UTC](https://discourse.julialang.org/t/leiden-algorithim-implementation-in-julia/55910/5 "2021-03-04T16:48:39Z")

</div>

Awesome, will do!

---

<div class="post-metadata">

**Author:** ![yottoo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yottoo/32/25782_2.png) [@yottoo](https://discourse.julialang.org/u/yottoo)\
**Post date:** [June 4, 2021, 5:31am UTC](https://discourse.julialang.org/t/leiden-algorithim-implementation-in-julia/55910/6 "2021-06-04T05:31:55Z")

</div>

> **[GitHub - yottoo/JuliaCommunity: A julia wrapper for Leiden algorithm to...](https://github.com/yottoo/JuliaCommunity)**
>
> A julia wrapper for Leiden algorithm to discover and plot the communities of a network. - GitHub - yottoo/JuliaCommunity: A julia wrapper for Leiden algorithm to discover and plot the communities o...

here is a julia wrapper for Leiden algorithm.
