Repository navigation
fix: Adjacency() makes self-loops from the diagonal for both graph kinds - #32
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
DGraph.Adjacency() raised ValueError('loops in graph not supported') on a
non-zero diagonal while UGraph.Adjacency() silently dropped it, and every
other entry point (connect, add_edge) permits self-loops. The diagonal is
now a self-loop, with the element as its cost, for both.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 10 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #32 +/- ##
==========================================
+ Coverage 90.31% 90.76% +0.45%
==========================================
Files 2 2
Lines 847 845 -2
==========================================
+ Hits 765 767 +2
+ Misses 82 78 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
DGraph.Adjacency()raisedValueError: loops in graph not supportedon a non-zero diagonal, whileUGraph.Adjacency()silently dropped it (it only read the strict upper triangle). Everything else (connect,add_edge) permits self-loops, so the factory was the one place that refused or lost them.A non-zero diagonal element
A[i, i]is now a self-loop on vertexi, with the element as its cost, for both graph kinds.Behavior change
DGraph.Adjacency()no longer raises for a diagonal. If rejecting loops there is preferred, it is a one-line change, but thenconnect()should reject them too for consistency.Notes
:raises:list is corrected to what actually raises.Tests
tests/test_adjacency_loops.py, 10 tests across both graph kinds.🤖 Generated with Claude Code