Repository navigation
refactor: graph.edges() returns a list in order of addition; both edges() return copies - #43
Merged
Merged
Conversation
… edges() methods return copies BaseGraph.edges() returned the graph's own set of edges (documented as a list), so it had no order, and it, like BaseVertex.edges(), handed out the live container: clearing the result emptied the graph's records without updating ne, and removing edges while iterating skipped some. The graph now keeps its edges in a dict used as an insertion-ordered set (keyed by the edge object, hashed by identity), so removal is still O(1), and both edges() methods return a new list. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 16 |
| 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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #43 +/- ##
=======================================
Coverage 94.61% 94.61%
=======================================
Files 3 3
Lines 1208 1208
=======================================
Hits 1143 1143
Misses 65 65 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Oct 11, 2026
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.edges()returns alistin order of addition, and bothgraph.edges()andvertex.edges()return copies. This supersedes #36, which made only the copy half of this change.What was wrong
BaseGraph.edges()returned the graph's ownsetof edges, although it was documented as a list (0.6.5:rtype: list of Edge references). So it had no defined order, and, likeBaseVertex.edges(), it handed out the live container: clearing the result emptied the graph's records without updatingne, and removing edges while iterating oververtex.edges()skipped some.Change
dict[Edge, None]used as an insertion-ordered set (keyed by the edge object, hashed by identity). Removal is still O(1), and the attribute is renamed_edgesso it no longer shares a name with the vertex's list.graph.edges()islist(self._edges),vertex.edges()islist(self._edgelist); both are new lists.graph.edges(), and carry aversionchangednote.incidence()numbered edges "in the order they appear ingraph.edges()" (now well defined) and claimeddegreecounts outgoing edges only (false since the degree change).Breaking change (1.0)
graph.edges()is alist, not aset: code that used set operations on the result (|,-,.add()) needsset(g.edges()). Downstream, RTB'sPoseGraphandLatticePlanneronly iterate it.Tests
tests/test_edges_list.py(22 tests, both graph kinds): type, order, order surviving removal, both results are copies, removing while iterating on both methods visits every edge, parallel edges, loops,Edge.remove,remove_vertex.🤖 Generated with Claude Code