Skip to content

feat: Vertex.edges_to() lists every edge from a vertex to another - #48

Merged
petercorke merged 1 commit into
mainfrom
feat/edges-to
Oct 12, 2026
Merged

petercorke merged 1 commit into
mainfrom
feat/edges-to

Conversation

@petercorke

Copy link
Copy Markdown
Owner

Summary

Adds Vertex.edges_to(dest), which returns every edge from a vertex to another vertex. edgeto(dest) is unchanged: it returns the one edge a path would use, the cheapest of any parallel edges, and the planners and RTB's LatticePlanner rely on that.

There was no way to inspect parallel edges short of filtering incidences() by hand.

a.edgeto(b)     # Edge: the cheapest a -> b (unchanged)
a.edges_to(b)   # list[Edge]: every edge a -> b, in connection order; [] if none

Behaviour

  • In connection order, a new list each call.
  • Empty list when there is no edge, not an error (edgeto still raises ValueError).
  • Directed graph: only edges from self to dest, so a.edges_to(b) and b.edges_to(a) differ.
  • Undirected graph: found from either end, whichever vertex they were connected from.
  • A self-loop is listed once, although its vertex holds it twice (that doubling is right for the degree, wrong for "the edges between these two vertices").

edgeto is now implemented on top of edges_to with the same result. Its precis and wording say "adjacent" rather than "neighbour". :seealso: links join edgeto and edges_to, and edges_to is added to the edges, out_edges and incidences families.

Tests

tests/test_edges_to.py (24, both graph kinds): single and parallel edges and their order, edgeto is the cheapest of edges_to, absence, other destinations excluded, loops (single and parallel), a new list, removal, undirected from either end including edges connected from the other end, directed one-way and opposite edges separate.

🤖 Generated with Claude Code

edgeto() returns the one edge a path would use, the cheapest of any parallel
edges.  There was no way to see the parallel edges themselves other than
filtering incidences() by hand.  edges_to() returns all of them, in
connection order, as a new list: empty rather than an error when there are
none, only the edges from self to dest for a directed graph, and an
undirected self-loop once, not once per end.

edgeto() is now built on it with the same result, and says adjacent rather
than neighbour.  The seealso links join the two and the edge-list family.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 17 complexity · 0 duplication

Metric Results
Complexity 17
Duplication 0

View in Codacy

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.

@petercorke
petercorke merged commit c64ffe1 into main Oct 12, 2026
12 checks passed
@petercorke
petercorke deleted the feat/edges-to branch October 12, 2026 01:20
@codecov

codecov Bot commented Oct 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.37%. Comparing base (1a424e6) to head (238b616).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #48      +/-   ##
==========================================
+ Coverage   95.27%   95.37%   +0.10%     
==========================================
  Files           3        3              
  Lines        1271     1277       +6     
==========================================
+ Hits         1211     1218       +7     
+ Misses         60       59       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant