Skip to content

Commit

Permalink
louvain -> leiden (modern)
Browse files Browse the repository at this point in the history
  • Loading branch information
timothewt committed May 22, 2024
1 parent 8fbf84f commit 4852722
Show file tree
Hide file tree
Showing 14 changed files with 218 additions and 107 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,5 @@ cython_debug/
.notebooks/figure/

output/

/notebooks/figures/
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Advanced Graph Clustering

This project focuses on the study and implementation of various graph clustering techniques, covering traditional techniques such as Spectral Clustering and Louvain Method, as well as deep graph clustering methods like Graph Autoencoders. The project aims to provide a comprehensive overview of graph clustering algorithms and their applications in network analysis.
This project focuses on the study and implementation of various graph clustering techniques, covering traditional techniques such as Spectral Clustering and Leiden Method, as well as deep graph clustering methods like Graph Autoencoders. The project aims to provide a comprehensive overview of graph clustering algorithms and their applications in network analysis.

## Table of Contents

Expand Down Expand Up @@ -49,10 +49,10 @@ py main.py --help

## Implemented Techniques
- Traditional Clustering Techniques:
- Louvain Method
- Markov Clustering Algorithm
- Spectral Clustering
- Stochastic Block Models
- Markov Clustering Algorithm
- Leiden Method
- Deep Graph Clustering:
- Graph Autoencoder (GAE)
- Adversarially Regularized Graph Autoencoder (ARGA)
Expand Down
Binary file modified notebooks/figures/autoencoder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified notebooks/figures/clusters_after.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified notebooks/figures/clusters_before.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified notebooks/figures/deep_framework.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified notebooks/figures/neural_network.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified notebooks/figures/neuron.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified notebooks/figures/small_graph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
301 changes: 205 additions & 96 deletions notebooks/tw-figures.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
from .deep.GAE import GAE
from .deep.ARGA import ARGA
from .traditional.Markov import Markov
from .traditional.Louvain import Louvain
from .traditional.Leiden import Leiden
from .traditional.Spectral import Spectral
from .traditional.SBM import SBM
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
from cdlib.algorithms import louvain
from cdlib.algorithms import leiden

from algorithms.Algorithm import Algorithm
from .utils import extract_clusters_from_communities_list


class Louvain(Algorithm):
class Leiden(Algorithm):
"""Louvain clustering algorithm
"""

def run(self) -> None:
"""Runs the algorithm
"""
clustering = louvain(self.graph.nx_graph)
clustering = leiden(self.graph.nx_graph)
self.clusters = extract_clusters_from_communities_list(clustering.communities)

def __str__(self):
Expand All @@ -20,4 +20,4 @@ def __str__(self):
:return: String representation of the algorithm object
:rtype: str
"""
return "Louvain algorithm object"
return "Louvain algorithm object"
2 changes: 1 addition & 1 deletion src/algorithms/traditional/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .Louvain import Louvain
from .Leiden import Leiden
from .Markov import Markov
from .SBM import SBM
from .Spectral import Spectral
4 changes: 2 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from graph import Graph
from algorithms import AdaGAE, GAE, ARGA, Markov, Louvain, SBM, Spectral
from algorithms import AdaGAE, GAE, ARGA, Markov, Leiden, SBM, Spectral


def main():
Expand Down Expand Up @@ -66,7 +66,7 @@ def main():
elif args.algorithm == "markov":
algo = Markov(graph, expansion=args.expansion, inflation=args.inflation, iterations=args.iterations)
elif args.algorithm == "louvain":
algo = Louvain(graph)
algo = Leiden(graph)
elif args.algorithm == "sbm":
algo = SBM(graph)
elif args.algorithm == "spectral":
Expand Down

0 comments on commit 4852722

Please sign in to comment.