puzzlef / leiden-communities-openmp-dynamic

Design of OpenMP-based Dynamic Leiden algorithm for community detection.
https://arxiv.org/abs/2405.11658
MIT License
0 stars 0 forks source link

A fresh try at fixing disconnected communities #5

Open wolfram77 opened 6 days ago

wolfram77 commented 6 days ago

This is the original vanilla code, not even refine till end pass.

Disconnected communities: 5.0E-4, Modularity: 0.4450

image

wolfram77 commented 6 days ago

We must run till convergence.

Disconnected communities: 5.1E-3, Modularity: 0.8845

image

wolfram77 commented 6 days ago

Handle data race while changing community (this doesn't seem to fix disconnected communities).

Disconnected communities: 6.1E-3 / 5.3E-3, Modularity: 0.8844 / 0.8842

image

Below are with details of where disconnected communities are getting created (refinement phase).

image

wolfram77 commented 6 days ago

Using a sequential refinement approach still produces disconnected communities - there is something else at play here.

image

wolfram77 commented 5 days ago

I added a batch update, directly after loading the graph. Even that is leading to disconnected communities. This disconnected communities issue is then clearly due to the property/nature of the graph, and not due to how the previous community membership may be disconnected due to the batch update!

image

image

wolfram77 commented 5 days ago

It seems most disconnected communities have just one missing vertex.

image

wolfram77 commented 5 days ago

It looks like the generated batch updated is not undirected, and also has duplicate edges. Stupid batch generation!

image

wolfram77 commented 5 days ago

After fixing symmetrizeOmpU(), leiden may rarely produce a few disconnected communities as follows.

image

A good atomic update may fix this issue.

NOTE: Indeed, a good atomic update does fix it!

wolfram77 commented 5 days ago

Now the process of optimizing the algorithm begins. Below is runtimes without optimizations. 2464ms

image

Ignoring affected vertices for refinement phase maybe helps a very tiny bit. 2191ms

image

Now doing a swap, instead of a copy - small to no benefit (or worse?). 2024ms

image

wolfram77 commented 4 days ago

Tracking affected communities seems to offer no advantage for large batch updates - however, we are getting some disconnected communities - need to fix. However, it may have good runtimes for small batch updates.

image

Fixing the issues required doing a full copy of community memberships as community bound, instead of a simple swap.

image

Although we are still seeing some rare (1/X) disconnected communities (1E-7 batch fraction).

image

With sequential refinement phase, this issue is not there, i.e., it does not introduce disconnected communities. So its a parallelism issue. But in some cases, disconnected communities is received as input, but why? Probably a subrefine related issue.

The input graph may have disconnected communities since a bridge got removed. This needs to be tracked, and such a community needs to be refined.

image

It seems the issue is now solved!

image

wolfram77 commented 4 days ago

Aggregation tolerance should have been enabled for large graphs!