Skip to content

Slimfly ring - #8118

Open
sean-chernov wants to merge 10 commits into
networkx:mainfrom
sean-chernov:slimfly_ring_clean
Open

sean-chernov wants to merge 10 commits into
networkx:mainfrom
sean-chernov:slimfly_ring_clean

Conversation

@sean-chernov

Copy link
Copy Markdown
Contributor

This module implements the Slim Fly network topology using the
McKay–Miller–Širáň (MMS) method with a primitive root over a commutative ring ℤ/qℤ.
Unlike the GF-based construction, this approach may not always achieve diameter 2,
but still yields low-diameter, high-connectivity graphs.

@sean-chernov

sean-chernov commented Jun 21, 2025 •

Copy link
Copy Markdown
Contributor Author

Hello,
I'm submitting a PR for the SlimFly graph generator, which is another example of a low-diameter network topology. I'm also preparing an updated version of the ER Polarity PR that removes the galois dependency.

I'm currently holding off on editing init.py and the documentation until I understand better how you'd prefer those changes structured. If either (or both) PRs are accepted, I’d be happy to create a dedicated category for low-diameter network topologies and include both there.

Also, just a quick reminder that there's an earlier PR open for k-lift as well — I’ll wait for feedback across all of these before proceeding further.

Thanks for your time and guidance!

@rossbar rossbar left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The test failures here look real so let's get those addressed before diving any deeper.

From a big-picture perspective this seems to fall in the same category as the ER/k-lift PR's i.e. the high-level discussion of how these types of generators fit in the library, but that discussion has already largely been started in other threads!

Comment on lines +85 to +99
# Move prime_factors inside the test function or make it a helper function if needed.
# It's not general utility, so keeping it closer to where it's used.
def _prime_factors_for_test(n):
"""Return the list of prime divisors of n."""
factors = []
while n % 2 == 0:
factors.append(2)
n //= 2
for i in range(3, int(np.sqrt(n)) + 1, 2):
while n % i == 0:
factors.append(i)
n //= i
if n > 1:
factors.append(n)
return factors

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Even though it's a private function, I think it'd be better to import it from it's original definition. Keeping multiple copies of a function definition around is a recipe for them falling out-of-sync over time!

@sean-chernov

Copy link
Copy Markdown
Contributor Author

Updated this PR to pass all checks. The main issue was the expectation we set in the example (which included a comment in addition to the expected value).
Additionally, we now import the prime factorization function from the main module instead of duplicating it in the test. Since it returns a set of unique factors (rather than a list with multiplicities), a small helper was added to recover the original test behavior.

@sean-chernov

Copy link
Copy Markdown
Contributor Author

Hi! Just wanted to check in. Are there any further changes you'd like me to make (aside from the final placement), or at this point is it more a question of whether the PR fit within NetworkX? Happy to adjust if needed!

This branch has not been deployed

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

Development

Successfully merging this pull request may close these issues.

2 participants