Skip to content

Conversation

@pnijhara
Copy link

@pnijhara pnijhara commented Dec 13, 2025

What does this PR change?

This PR implements the parallel maximal independent set via Luby's random permutation mechanism (solving issue #144)

  • Add parallel implementation of maximal_independent_set algorithm
  • Implements Luby-style randomized parallel algorithm for speedup on large graphs (50K+ nodes)
  • Works best on large graphs (n>50,000)

What is your approach, and why did you choose it?

A standard parallel MIS algorithm assigns a random priority to every vertex once per round, then selects all locally maximal vertices at the same time:

while graph not empty:
    generate random priority for each vertex
    S = { u | priority(u) > priority(v) for all v in N(u) }
    add S to MIS
    remove S ∪ N(S) from graph

Why this is parallel:

  • Priority comparisons for all vertices are independent operations.
  • Set S can be selected in one parallel pass.
  • All vertices in S are guaranteed independent.
  • Removing S ∪ N(S) can also be done in parallel.

This matches the PRAM formulation and is widely used in CPU and GPU environments.

Brief summary of changes (1–2 lines)

  • Added a file algorithms/mis.py
  • Added tests for algorithms/mis.py in algorithms/tests/test_mis.py
  • Found in the local benchmark tests that for node count less than 50K, sequential code is working best; however, for larger graphs such as n = 100K and 1M, parallel code is working best. This may be because of joblib's parallelization overhead. I tested this in C++ with OpenMP. The same issue persists there, but with a lesser node count.

@pnijhara pnijhara changed the title [DRAFT] Added functionality of parallel maximal independent set [WIP] Added functionality of parallel maximal independent set Dec 13, 2025
@pnijhara
Copy link
Author

@dschult please review it.

@Schefflera-Arboricola Schefflera-Arboricola added the type: Enhancement New feature or request label Dec 13, 2025
Copy link
Member

@dschult dschult left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

Some formatting suggestions before diving into the code/tests:

  • we typically don't put error messages on the "assert" command. The pytest report of the assert failure is sufficient.
  • we also typically dont include a comment line at the beginning of the test when the test function's name is sufficient. If the test involves soemthing special or unexpected, then a couple line doc_string (or comment) is used. We aren't building docs for the tests.
  • instead of building a sequential version of the code inside nx-parallel, does it make sense to just "fall back" to the NetworkX version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: Enhancement New feature or request

Development

Successfully merging this pull request may close these issues.

Add parallel implementation of Combinatorial Algorithms

3 participants