Open cheginit opened 2 days ago
Awesome - I've noted it in #227 which is the overview of subbasin delineation/community detection issue.
This algorithm is also included in igraph directly: https://python.igraph.org/en/stable/api/igraph.Graph.html#community_leiden
The igraph version is faster but less flexible (fewer objective functions, no support for directed graphs) than the leidenalg version.
Thanks @szhorvat - igraph
looks super helpful, as ultimately, I would envisage offering a range of options for a user to further customise the communities. I think it is fine to have just modularity objective and use of undirected graphs in this case - indeed that is how this community detection step currently works. The only point at which swmmanywhere
requires a directed graph is for shortest path optimization of the pipe network topology, since slope is a directed variable. But community detection in this step is more focussed on eliminating or retaining potential pipe-carrying links based on the hydrological subbasins and the road network communities (more info in #227 ).
While working on a project, I found this package called
leidenalg
. Based on my experience, it produces higher quality communities than Networkx's Louvain and tends to be faster. Here's an example of how it can be used to generate communities from anetworkx
graph object: