Repository navigation
feat: add_edge() accepts an Edge as well as two vertices - #27
Merged
Merged
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
g.add_edge(MyEdge(v1, v2)) now works, mirroring add_vertex() which takes coordinates or an existing vertex. The edge must already carry both vertices; extra cost/data arguments are rejected since connect() would silently ignore them. add_edge() (either form) now also refuses vertices that belong to a different graph instead of silently adding the edge to that graph. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 20 |
| Duplication | 1 |
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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #27 +/- ##
==========================================
+ Coverage 87.37% 87.59% +0.21%
==========================================
Files 2 2
Lines 800 814 +14
==========================================
+ Hits 699 713 +14
Misses 101 101 ☔ 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
graph.add_edge()now accepts anEdgethat already carries both vertices, mirroringadd_vertex(), which takes coordinates or an existing vertex.The existing
add_edge(v1, v2, **kwargs)forms are unchanged, so this is purely additive.Behavior
add_edge(e)requirese.v1ande.v2; otherwiseValueError, with a message pointing atadd_edge(v1, v2, edge=e)/e.connect(v1, v2).add_edge(e, v2)is aTypeError.add_edge(e, cost=...)/data=...is aTypeError:connect()would silently ignore them when given an edge.@overload.One behavior tightening
add_edge()(both forms) now raisesValueErrorif the vertices belong to a different graph. Previouslyg.add_edge(x, y)withx,yfrom graphhsilently added the edge toh.Tests
tests/test_add_edge_edge.py, 21 tests acrossUGraphandDGraph. mypy: no new errors.🤖 Generated with Claude Code