Clarify expected behavior for Leiden on a disconnected graph
See original GitHub issueIs your feature request related to a problem? Please describe.
Several times I have been confused by output of Leiden only to realize it is because some nodes are disconnected. These nodes then will not show up in the partition dictionary.
Describe the solution you’d like
Just some clarification and/or a warning for what to expect
Provide references (if applicable)
in this example node 0 is disconnected from the graph and thus key 0 is not present in the output dictionary
g = nx.complete_graph(10)
nodelist = sorted(g.nodes)
for node in nodelist[1:]:
g.remove_edge(0, node)
leiden(g)
{3: 0, 4: 0, 7: 0, 2: 0, 9: 0, 6: 0, 5: 0, 1: 0, 8: 0}
cc: @daxpryce
Issue Analytics
- State:
- Created 2 years ago
- Comments:26 (13 by maintainers)
Top Results From Across the Web
From Louvain to Leiden: guaranteeing well-connected ...
In our experimental analysis, we observe that up to 25% of the communities are badly connected and up to 16% are disconnected. To...
Read more >Leiden-Based Parallel Community Detection
Leiden is a community detection algorithm, that seeks to maximize modularity by dividing a graph into densely connected disjoint sets of nodes. ...
Read more >arXiv:1810.08473v3 [cs.SI] 30 Oct 2019
First, we show that the Louvain algo- rithm finds disconnected communities, and more gener- ally, badly connected communities in the empirical ...
Read more >(PDF) From Louvain to Leiden: guaranteeing well-connected ...
In our experimental analysis, we observe that up to 25% of the communities are badly connected and up to 16% are disconnected. To...
Read more >igraph.pdf - The Comprehensive R Archive Network
Description Routines for simple graphs and network analysis. It can handle large graphs very well and provides functions for generating random.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Might I suggest a different approach?
Doing it this way means fewer check flags, which are an evil (though sometimes necessary), and also somewhat keeps the divergent-paths-depending-on-graph-representation-type stuff to a minimum
I don’t know that the LCC should matter - it makes sense that your embeddings lose coherency/utility, but > 1 CC is perfectly fine in the leiden case. I don’t think we should lcc check, but we should make sure we warn if we’re returning a partitions dictionary that doesn’t contain a partition for every node 😃