Repository navigation
Conversation
Build the ordered weighted triples directly for simple string-keyed graphs. Keep isolate numbering and native partition output stable, and construct the canonical NetworkX graph on demand for fallbacks. Builds on the partition-cache work in f51d46c and preserves Graphify-Labs#3146. Co-Authored-By: Codex <noreply@openai.com>
|
Thanks for the pull request, @Max17190. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.11 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify review 
2 possible issues to check · High impact
The partitioner now prepares canonical Leiden edge tuples directly for ordinary graphs with string node IDs, building the stable graph only when that fast path cannot be used.
2 possible issues we couldn't confirm
- Partitioning can crash on non-numeric edge weights that the old sort key accepted ·
graphify/cluster.py:277 - Canonical-edge test asserts inside the fake native Leiden, so a mismatch can be swallowed by the fallback path ·
tests/test_cluster.py:209
They don't change the score.
Code graph · 860 functions depend on this change
- 1 function became more coupled.
_partition()(4 callers). - 23 of 613 test files are affected by this change.
- Gate, test list and every flagged function: in the Graphify check.
Reviewed 0e2439f · Full report in the Graphify check
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Why
Graphify's native Leiden path builds a second NetworkX graph and copies edge attributes into it. The next step reads that graph back as weighted endpoint triples. The stable graph matters for fallback backends. Native Leiden only needs the sorted triples and deterministic isolate ordering.
Closes #5405.
Summary
Type of change
Verification & Invariants
The optimized path passes the same ordered triples to the same Leiden call. Loaded-graph comparisons preserve exact partition IDs and complete community output. A differential sweep compares 3,000 randomized graphs and 135 edge-attribute, graph-shape, and fallback cases against v8, across three hash seeds.
Benchmarks
Apple M5, CPython 3.13.9, NetworkX 3.7, and graspologic-native 1.3.1. Each row is five interleaved baseline/candidate pairs with a fresh output directory seeded by the same
graph.json. Stdout, stderr, and SHA-256 of all five output artifacts match across both versions on each corpus.Graphify and Guava improve in all five pairs, with median elapsed reductions of 8.8% and 7.8%. The Django CLI result is inconclusive. With the graphs already loaded, median weighted
cluster()time fell by 34% to 35% on all three corpora.How was this tested?
Test Plan
graphify cluster-only . --no-labelusing a fresh partition cache for each measured invocation.ruff check .andgraphify update ..Graphify-specific checklist