question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clarify expected behavior for Leiden on a disconnected graph

See original GitHub issue

Is 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:closed
  • Created 2 years ago
  • Comments:26 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
daxprycecommented, Aug 31, 2021

Might I suggest a different approach?

if isinstance(graph, nx.Graph):
  # check if graph.number_of_nodes() == len(partitions), if not, we can presume isolates are removed
else if <is matrix form>:
  # check if graph.shape[0] == len(partitions), if not, we can presume isolates are removed

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

1reaction
daxprycecommented, Aug 31, 2021

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 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found