Python implementation of the LAGO method...
Project description
Dynamic Community Detection: LAGO
This library is a python implementation of the LAGO method for dynamic community detection on temporal networks.
Getting started using pip
pip install dcd-lago
Link Streams and Dynamic Communities
Link stream (or stream graph) model enables temporal network to have perfect temporal precision of temporal links (also called edges or interactions).
Community detection is an essential task in static network analysis. It consists in grouping nodes so there is more edges within groups than between them. Adapating this task to temporal networks means that groups may evolve over time and yet be consistent over time. We call this task Dynamic Community Detection.
Figure 1: Link stream made up of 5 nodes (a, ...,e) with time interactions over time represented with vertical dashed lines. Two dynamic communities are displayed in blue and green.
LAGO (Longitudinal Agglomerative Greedy Optimization) is a method to detect dynamic communities on link streams which is inspired from most used community detection methods on static graphs. It is based on the greedy optimization of the Longitudinal Modularity, an adaptation of the Modularity quality function for communities on static networks.
Usage
from lago import LinkStream, lago_communities
## Declare time links according to the following format:
# <source node>, <target node>, <time instant>
## Values must be integers
time_links = [
[2, 3, 0],
[0, 1, 2],
[2, 3, 3],
[3, 4, 5],
[2, 3, 6],
[2, 4, 7],
[0, 1, 8],
[1, 2, 9],
[3, 4, 9],
[0, 2, 10],
[1, 2, 11],
[3, 4, 13],
[1, 2, 14],
[2, 4, 16],
[0, 1, 17],
[0, 1, 18],
[2, 3, 18],
[3, 4, 19],
]
## Initiate empty temporal network (as a link stream)
my_linkstream = LinkStream()
## Add time links to the link stream
my_linkstream.add_links(time_links)
# NOTE time links can also be imported from txt files with the read_txt() method
## Display linkstream informations
print(f"The link stream consists of {my_linkstream.nb_edges} temporal edges (or time links) accross {my_linkstream.nb_nodes} nodes and {my_linkstream.network_duration} time steps, of which only {my_linkstream.nb_timesteps} contain activity.")
## Compute dynamic communities
dynamic_communities = lago_communities(
my_linkstream,
nb_iter=3, # run LAGO 3 times and return best result
)
# Each dynamic community is represented by a list of (<node>, <time instant>)
print(f"{len(dynamic_communities)} dynamic communities have been found")
Plot Dynamic Communities
from lago import plot_dynamic_communities
fig = plot_dynamic_communities(
linkstream=my_linkstream,
communities=dynamic_communities,
)
fig.show()
Compute Longitudinal Modularity Score
from lago import longitudinal_modularity
## Compute Longitudinal Modularity score
## (the higher the better / maximum is 1)
long_mod_score = longitudinal_modularity(
my_linkstream,
dynamic_communities,
)
print(f"Dynamic communities detected on the linkstream have a Longitudinal Modularity score of {long_mod_score} ")
Advanced Parameters
LAGO is a greedy method for optimizing Longitudinal Modularity, which is a quality function for dynamic communities on temporal networks. Both have many options which affects both speed and communities shapes.
Longitudinal Modularity
lex (Longitudinal Expectation):
Can be either Joint-Membership (JM) or Mean-Membership (MM). From a theoretical aspect, JM expects dynamic communities to have a very consistent duration of existence, whereas MM allows greater freedom in the temporal evolution of communities. Authors lack perspective on the impact of the choice on real data. Defaults to "MM".
omega: Time resolution Parameter indicating the required level of community continuity over time. Higher values lead to more smoothness in communities changes. Defaults to 2.
LAGO
refinement: In greedy search optimization, a refinement strategy can improve results but increases computation time. Defaults to STEM.
| Refinement | Improvement | Time of execution |
|---|---|---|
| None | - | - |
| Single Time Node Movements (STNM) | + | + |
| Single Time Edge Movements (STEM) | ++ | ++ |
refinement_in: Whether to apply refinement strategy within the main optimization loop or not. If activated, results may be improved but requires more computation time. Defaults to True.
fast_exploration: lighter exploration loop. If activated, it significantly reduces the time of execution but may result in poorer results. Defaults to True.
Feedback
LAGO method and the python library are constantly improving. If you have any questions, suggestions or issues, please add them to GitHub issues.
References
LAGO Method
Discovering Communities in Continuous-Time Temporal Networks by Optimizing L-Modularity (preprint)
@misc{brabant2025discoveringcommunitiescontinuoustimetemporal,
title={Discovering Communities in Continuous-Time Temporal Networks by Optimizing L-Modularity},
author={Victor Brabant and Angela Bonifati and Rémy Cazabet},
year={2025},
eprint={2510.00741},
archivePrefix={arXiv},
primaryClass={cs.SI},
url={https://arxiv.org/abs/2510.00741},
}
Longitudinal Modularity
Longitudinal Modularity, a Modularity for Link Streams
@article{Brabant2025,
title = {Longitudinal modularity, a modularity for link streams},
volume = {14},
ISSN = {2193-1127},
url = {http://dx.doi.org/10.1140/epjds/s13688-025-00529-x},
DOI = {10.1140/epjds/s13688-025-00529-x},
number = {1},
journal = {EPJ Data Science},
publisher = {Springer Science and Business Media LLC},
author = {Brabant, Victor and Asgari, Yasaman and Borgnat, Pierre and Bonifati, Angela and Cazabet, Rémy},
year = {2025},
month = feb
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dcd_lago-1.0.3.tar.gz.
File metadata
- Download URL: dcd_lago-1.0.3.tar.gz
- Upload date:
- Size: 21.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0c05de08e225ebc06b2e6fa483c6f9e29354630946a47c49402f3229dfaa61e
|
|
| MD5 |
4c3c40aa7e61a95e2286df085eee3103
|
|
| BLAKE2b-256 |
4cf5b4ac52197dab6a748eb181b9affdaf9a166926a6710136f01c345878d2c9
|
File details
Details for the file dcd_lago-1.0.3-py3-none-any.whl.
File metadata
- Download URL: dcd_lago-1.0.3-py3-none-any.whl
- Upload date:
- Size: 28.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
502386a468ed07b7725e8f61f37a3ff7a0431f1f230d7c5b72e5b05d1d0f8120
|
|
| MD5 |
f31f713ef04c2e4a62d2a010f633e904
|
|
| BLAKE2b-256 |
e755b4cf9907de3cd826dcd247d3581de19934f4d3ddf9444011735ba64c6daf
|