Repository navigation
fix: Keep rejecting directed graphs in cluster_leiden(), and pin its reported quality - #2996
Merged
Merged
Conversation
…lity Directed input is rejected with the C core's error, for the modularity and CPM objectives and for weighted graphs. On undirected graphs, the reported `$quality` of the modularity objective agrees with `modularity()` at the same resolution, for an unweighted and a weighted graph, and the resolution moves the partition between one community and singletons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015GouVEqbVWVYs6hH8zvrRc
…C core The C core accepts directed graphs from igraph 1.0 on, but this wrapper passes no in-weights and scales the resolution for undirected modularity, so on a directed graph it would silently optimize the wrong objective. The check in R keeps the behaviour of igraph 2.3.4 across the engine upgrade, with the message the C core raises today. The R side of 9ad4bcb on `claude/f1-leiden-directed`, without its tests, which this branch already carries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JXnA76zWTu4ZD8BQCSYRpk
Contributor
|
This is how benchmark results would change (along with a 95% confidence interval in relative change) if c528af9 is merged into main:
|
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.
cluster_leiden()now rejects a directed graph in R, before it calls the C core, and three new tests pin what the function does today. This is the first of five stacked pull requests that bring work from the vendoring series tomainahead of the C core 1.0 upgrade.What it changes
cluster_leiden()raises "Leiden algorithm is only implemented for undirected graphs." for a directed graph, right afterensure_igraph(graph). Onmainthe vendored C core already raises the same message, so the behaviour does not change; only the error now comes from R. The C core accepts directed graphs from igraph 1.0 on, but this wrapper passes no in-weights and scales the resolution for undirected modularity, so on a directed graph it would silently optimize undirected modularity at twice the resolution, and its$qualitywould disagree withmodularity(). The check keeps the behaviour of igraph 2.3.4 across the engine upgrade. Proper directed support would need the in-weights exposed and the resolution scaled by the edge count, which is beyond this fix.The new tests in
tests/testthat/test-community.R:$qualityof the modularity objective equalsmodularity()of the returned membership, at resolutions 0.5, 1 and 2 on the karate graph and on a weighted pair of triangles.man/cluster_leiden.Rdnow also linksigraph_is_directed()under "Related documentation in the C library", which the C-docs roclet derives from the new call.This supersedes the series-side fix in draft #2991: the R check is the R side of 9ad4bcb on
claude/f1-leiden-directed, without its tests, which this branch already carries.Checks
devtools::document()produced theman/cluster_leiden.Rdchange above, committed here;air formatchanges nothing.test-community.Rpasses all 36 blocks against a build of this branch, and the tests also pass onmainwithout the R check.LLM use: this PR was prepared with Claude Code (Claude Opus 5.5), at the maintainer's request. The tests and the R check come from the subsession https://claude.ai/code/session_015GouVEqbVWVYs6hH8zvrRc.
Generated by Claude Code